| 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  |
| 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
 |
| 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.  |
| 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  |
| 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  |
| 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.  |
| Pramod Kumar |
| |
| |
| Answer | Using RequestDispatcher as follows,
RequestDispatcher rd =
getServletContext().getRequestDispatcher("test.jsp");
rd.forward(req,res);  |
| 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);
}
 |
| 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>
...  |
| 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>  |
| 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()  |
| Ravikiran(aptech Mumbai) |
| |
| |
| Answer | DataSource.getConnection()  |
| 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()  |
| 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  |
| Tulasi Vani |
| |
| |
| Answer | Servlets can communiceate with the help of RequestDispacher.
RequestDispacher rd = getRequestDispacher("passing the 2nd servlet url");
rd.forward(rquest,response);  |
| 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  |
| Niranjanravi |
| |
| |
| Answer | Store the variable in the session.  |
| 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");  |
| 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  |
| Niranjanravi |
| |
| |
| Answer | During servicing any request the container will create a
thread or will get a thread from a thread pool.  |
| Ravikiran(aptech Mumbai) |
| |
| |
| Answer | Web Container will create a Thread for each request!  |
| 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  |
| Niranjanravi |
| |
| |
| Answer | For every request servlet container will create a new
thread and service method is called  |
| 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.  |
| 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  |
| 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.  |
| 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.  |
| 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  |
| 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  |
| Kunal Sagar |
| |
| |
|
| |
|
Back to Questions Page |