ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories >> Software >> Java-Related >> Java-J2EE >> Servlets
 
 


 

Back to Questions Page
 
Question
what are the way a client can be tracked?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   IBM , Abc
I also faced this Question!!   © ALL Interview .com
Answer
Refer

http://www.onjava.com/pub/a/onjava/excerpt/jebp_3/index1.htm
l?page=4


sandhya S
 
0
Guest
 
 
Question
How many Cookies can a host support?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
two types of cookjies are used in hosting support
 
0
Guest
 
 
Answer
The browser is expected to support 20 cookies for each Web 
server, 300 cookies total, and may limit cookie size to 4 
KB each.
 
0
Anji
 
 
 
Question
How to handle the debug errors in servlets?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
If you are using any tool debug the code using the tool's 
debugger it will help you a lot
 
0
Pramod Kumar
 
 
Answer
debigging the errors in servlets is very difficult.........
if we want to detect the errors in servlet we have to print 
the object ......... for ex----
           Connection con=DriverManager("url","uid",pwd");
           System.out.println(con);
           if it prints the object address the program is 
connected to database otherwise not connected to database
 
0
Sk
 
 
Question
How to pass JavaBeans data to JSP using Servlets?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
<jsp:useBean> tag can be used to avail the bean data in 
case you are working with JSP's, or if you use a servlet 
you can set the bean to the request object and forward it 
to the JSP component and there in JSP retreive this object 
and use getter methods and do something like this and it 
works for sure.
 
0
Pramod Kumar
 
 
Answer
Using RequestDispatcher as follows,

RequestDispatcher rd = 
getServletContext().getRequestDispatcher("test.jsp");
rd.forward(req,res);
 
0
Muralisankar
 
 
Question
How an Image can be loaded in a Servlet ?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
Try to use this code it may help you
public class MessageImage {
/** Creates an Image of a string with an oblique
* shadow behind it. Used by the ShadowedText servlet
* and the ShadowedTextFrame desktop application.
*/
public static Image makeMessageImage(String message,
String fontName,
int fontSize) {
Frame f = new Frame();
// Connect to native screen resource for image creation.
f.addNotify();
// Make sure Java knows about local font names.
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
env.getAvailableFontFamilyNames();
Font font = new Font(fontName, Font.PLAIN, fontSize);
FontMetrics metrics = f.getFontMetrics(font);
int messageWidth = metrics.stringWidth(message);
int baselineX = messageWidth/10;
int width = messageWidth+2*(baselineX + fontSize);
int height = fontSize*7/2;
int baselineY = height*8/10;
Image messageImage = f.createImage(width, height);
Graphics2D g2d =
(Graphics2D)messageImage.getGraphics();
g2d.setFont(font);
g2d.translate(baselineX, baselineY);
g2d.setPaint(Color.lightGray);
AffineTransform origTransform = g2d.getTransform();
g2d.shear(-0.95, 0);
g2d.scale(1, 3);
g2d.drawString(message, 0, 0);
g2d.setTransform(origTransform);
g2d.setPaint(Color.black);
g2d.drawString(message, 0, 0);
return(messageImage);
}

 
0
Sagar
 
 
Question
How to invoke a Servlet?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Mastek
I also faced this Question!!   © ALL Interview .com
Answer
<form action="/servlet/full.class.name">
</form>


This method uses the invoker servlet, provided by many 
servlet containers. The much better way of invoking a 
servlet is by providing an explicit mapping for it. This is 
accomplished by using a pair of tags in your web 
application's web.xml file. This is not the same file as 
mentioned above. That file was located in Tomcat's conf/ 
directory. This web.xml file (which you will probably need 
to create) will reside in your web-application's WEB-INF/ 
directory. For each servlet you want to call, provide a 
pair of tags like the following: 


...
<servlet>
    <servlet-name>HelloWorld</servlet-name>
    <servlet-class>your.package.name.HelloWorld</servlet-
class>
</servlet>
...
<servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>/hello</url-pattern>
</servlet-mapping>
...
 
5
Dara
 
 
Answer
you can invoke the servlet by two ways
one is dierctly u can invoke from address bar
like the following
http://<servername>:<port-Number>/<web-application-name>/<url-pattern
of perticular servlet>

eg:- http://localhost:8080/app1/test

second one is u can invoke by using form..
<form action="/app1/test">
.....
.....
</form>

web.xml:-

<servlet>
    <servlet-name>FirstServlet</servlet-name>
    <servlet-class>pack1.pack2.ClassName</servlet-class>
</servlet>
<servlet-mapping>
     <servlet-name>FirstServlet</servlet-name>
     <url-pattern>/test</url-pattern>(test should be equal
to what u typed in the address bar after the web-application
name or should be equal to what u mention in the form action
after the web-application name)
</servlet-mappin>
 
5
Chandra Kunchala
 
 
Question
What method is used to create database connection in 
servlets?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
either using DriverManager.getConnection
(or)
DataSource.getConnection()
 
0
Ravikiran(aptech Mumbai)
 
 
Answer
DataSource.getConnection()
 
0
Raghu
 
 
Question
How to debug a servlet?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
through servletloginfo()
 
0
Niranjanravi
 
 
Question
How two servlets communicate with each other?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
Servlets communicate with each other with the help of 
RequestDispatcher objects.

RequestDispatcher rd=getServletConfig().getNamedDispatcher
(...);

... name used to identify a servlet i.e. name given in the 
web.xml in the url-pattern
 
0
Tulasi Vani
 
 
Answer
Servlets can communiceate with the help of RequestDispacher.

RequestDispacher rd = getRequestDispacher("passing the 2nd servlet url");
rd.forward(rquest,response);
 
0
Devendra
 
 
Question
How variables can be accessed across the sessions?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
through session context interface
 
0
Niranjanravi
 
 
Answer
Store the variable in the session.
 
0
Anji
 
 
Answer
we have to set the variable in session object.like
session.setAttribute("somename",varible name);
and then we can get this variable where we want in this 
session 
session.getAttribute("somename");
 
0
Mohan
 
 
Question
How threads are implemented in servlets?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
internally the threads are implemented in servlets
 
0
Niranjanravi
 
 
Answer
During servicing any request the container will create a
thread or will get a thread from a thread pool.
 
0
Ravikiran(aptech Mumbai)
 
 
Answer
Web Container will create a Thread for each request!
 
0
Prashant Rajput
 
 
Question
How multiple simultaneous requests can be handled by 
servlets?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
using Threads
 
0
Niranjanravi
 
 
Answer
For every request servlet container will create a new 
thread and service method is called
 
0
Sudheer
 
 
Question
How servlets can be automatically reloaded?
Rank Answer Posted By  
 Question Submitted By :: Guest
I also faced this Question!!   © ALL Interview .com
Answer
depends on the servlets reload properties.
 
5
Niranjanravi
 
 
Answer
if in your deployment descriptor or <web.xml> file you have 
set <load-on-startup>1</load-on-startup> then it will  be 
auto matically loaded
 
0
Bibek
 
 
Question
How to run a servlet program?
Rank Answer Posted By  
 Question Submitted By :: Guest
This Interview Question Asked @   Infosys
I also faced this Question!!   © ALL Interview .com
Answer
We have to Make a WEB-INF folder and under it classes 
folder. In WEB-INF we have to write web.xml .

Our compled servelet class file should be stored in classes 
folder.

Make a war file using jar & deploy in Web.
 
0
Subrahmanyam
 
 
Answer
The structure of the web app. is
demo[root]
 - all jsps will go her
 - WEB-INF
   - web.xml
   - tld files
   - classes
     - all java class files will go here

Compile all the files and create a war file
copy the war file into Tomcat_root\webapps folder
if you use weblogic or webspehere the deployment will be 
different.
 
0
Anji
 
 
Answer
we have make dir name is,WEB-INF is the root directory
    WEB-INF
         --classes dir
         --lib dir
         --src dir
         --web.xml
      -html file
      -dhtml file
      -jsp file

lib dir contains
      --jasper-runtime.jar
      --servlet-api.jar
      --jsp-api.jar

your source code put in the src dir

--put the WEB-INF dir in your tomcat server and run the servlet
 
0
Suresh
 
 
Answer
first we con compile the java code throught javac compiler.
then,its .class file will be created that .class file copy 
and paste the in the directory
c:/program files/apache/tomcat/webapps/servlet/web-inf
/classes.
then back one step backward
change the servlet code with ur file name
and also sevlet mapping code with ur file name
save that file
then open explorar
and type the local host address
 
0
Kunal Sagar
 
 
 
Back to Questions Page
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com