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
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
 
3
Venkat
 
 
Answer
Using <form tag>
ex : <form action=controller method=post>

The action controller is mapping in web.xml.
 
0
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
 
0
Shivom Srivastava
 
 
 
Answer
we have methods like 
String st=ServletRequest.getParameter(String );
Enumeration en=ServletRequest.getParameterNames(String);
ServletRequest.getParameterValues(int value);
 
0
Saikiran
 
 
Answer
The values passed through the HttpRequest object.

Example:
          request.getParameter("Key Value given in the 
JSP/HTML Page");
 
0
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");
 
0
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
 
0
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
 
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.
 
5
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
 
 
 
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