| Back to Questions Page |
| |
| Question |
How values can be passed from HTML page to servlet? |
Rank |
Answer Posted By |
|
Question Submitted By :: Guest |
| This Interview Question Asked @ ABC |
|
I also faced this Question!! |
© ALL Interview .com |
| Answer | Using QueryString  |
| Venkat |
| |
| |
| Answer | Using <form tag>
ex : <form action=controller method=post>
The action controller is mapping in web.xml.  |
| Samsudeen |
| |
| |
| Answer | We can use BEAN's getters and setters to get the the value
from the html pages.
At least in case of struts we do the same  |
| Shivom Srivastava |
| |
| |
|
|
| |
| Answer | we have methods like
String st=ServletRequest.getParameter(String );
Enumeration en=ServletRequest.getParameterNames(String);
ServletRequest.getParameterValues(int value);  |
| Saikiran |
| |
| |
| Answer | The values passed through the HttpRequest object.
Example:
request.getParameter("Key Value given in the
JSP/HTML Page");  |
| Mani |
| |
| |
| Answer | we can pass the values to servlet through from HTML Page as follows:-
create a form --> define <form action=Ser>
where Ser is a servlet java class in which we want to retrieve the value.in web-xml in <servlet> tag class name will be defined.
In Ser.java we can retrieve the value by writing as follows:
String login=request.getParameter("login");  |
| Dadhich |
| |
| |
| Answer | there are two ways in passing form data to a servlet
in case of the form using GET method
-------------------------------------
the form data is appended as a query string after the
end of the url in the address bar of the browser
in case of the form using POST method
--------------------------------------
the form data is added to the body part of the Http
protocol request body .this form data is called as payload  |
| Satya |
| |
| |
| 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 |
| |
| |
|
| |
|
Back to Questions Page |