Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  




Share on Google+Share on Google+

1 Answer(s)      8 years ago
Posted in : Servlet Interview Questions
View Answers

August 12, 2008 at 1:03 PM

Servlet Request

1.public abstract interface ServletRequest

2.A ServletRequest object provides data including parameter name and values, attributes, and an input stream.

Interfaces that extend ServletRequest.

3.ServletRequest is not responsible for retrieving HTTP properties.

4.There are in total 29 methods.

For ex: Method Used

String getRemoteAddr()

String getRemoteHost()

String getProtocol()

String getScheme()

String getRealPath( String path )

int getRemotePort()


1)javax.servlet.http Interface HttpServletRequest

2)Extends the ServletRequest interface to provide request information for HTTP servlets.

3)HttpServletRequest interfaces is related to URL/URI in HttpServletRequest as compared to the server

and ports in ServletRequest.

For ex.

String getMethod()

String getPathInfo()

String getQueryString()

String getRemoteUser()

String getRequestURI()

StringBuffer getRequestURL()

String getServletPath()

String getContextPath()

4).Set the content type


Servlet Response

1)javax.servlet Interface ServletResponse.

2)A servlet in sending a response to the client.

3)The servlet container creates a ServletResponse object and passes

to servlet's service method.

4)Method Used in ServletResponse

for e.g flushBuffer()


setContentType(java.lang.String type)

void setBufferSize(int size)


Interface HttpServletResponse

1)It extends the ServletResponse interface

2)It provide HTTP-specific functionality in sending a response.

3)Methods to access HTTP headers and cookies.

For e.g Method Used



4)Set the Content type.

HttpServletResponse.setHeader("Content-Type", "text/html");


Read for more information with example

Thanks & Regards



Related Tutorials/Questions & Answers:
Servlet  What is Servlet
Servlet  how to navigate one servlet page to another servlet page
servlet  How many times the servlet is accessed
servlet  is there any way to include pdf's in servlet
servlet  what are the methods and interfaces in the servlet api ?   Servlet Tutorials
servlet  what are the all necessary configuration to run a servlet
servlet  how to interact with a servlet from a swing program
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet  I designed 1 html form & a servlet but when I click on form I don't get output of servlet Please help
servlet  i want to create a login page with servlet using database mysql? only in servlet not in jsp plzz help me out
override Service method in the servlet when you extend GenericServlet to create servlet as it is mandatory to override it. But, when you extend HttpServlet to create a servlet then you can't override service method as there is a need to override
Servlet  What must be implemented by all Servlets?    The Servlet Interface must be implemented by all servlets
servlet  i want a program for counting the no of times the servlet has been invoked
servlet  how to create a login form using servlet using submit,edit delete button
servlet  dear sir servlet and html not run on eclips plz help me
servlet  can i stoar record in variable which selected from table in servlet
of the Servlet API. It contains the classes necessary for a standard, protocol-independent servlet. Every servlet must implement the Servlet interface in one
Servlet  I want to know the steps to write a simple servlet program... .   Hello Friend, Follow these steps: Put servlet-api.jar inside the lib folder of apache tomcat. 1)create a servlet. import*; import
Servlet   Why is Servlet so popular?   Because servlets are platform-independent Java classes that are compiled to platform-neutral byte code that can be loaded dynamically into and run by a Java technology-enabled Web
servlet  i want to use servlet application on my web page then what should i do. I have already webspace.   Hi Friend, Please visit the following link: Servlet Tutorials Thanks
servlet  how to read a file from different folder using filereader in servlet   Hello Friend, Please visit the following link: Here you will get an useful
Servlet  Can a user defined function be included in a servlet? I need information regarding servlet syntax and not JSP.   Yes, you can create user defined function in Servlets. Have a look at the following link: http
servlet  I want the full coding for uploading a file in local drive D usin jsp,java class and servlet... help me thanks in advance....   ... and servlet please and thanks in advance
Servlet  Hi, Can any one please expalin me below topics SERVLET ENGINE 2.WHY SUPER.INIT(); Thanks alot in advance!! Regards: Akash
servlet   Dear Deepak, is it compulsary to write the sevice() becoz i ve seen some example which does not ve sevice() it tue? plz replay me with thanks praveen
servlet  plz can anyone give me the link of javax library jar file. i badly need that. thanks in advance   Please visit the following link: Download Servlet API
servlet  I want a fully readymade project on online voting system with code in java servlet and database backend as msaccess.can u plz send me as soon as possible
the same error <web-app> <servlet> <servlet-name>InsertServlet</servlet-name> <servlet-class>InsertServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>
servlet file which prints out the user's inputs. I need to use the post method to pass the data from html to the java servlet and also use both doGet and doPost methods in the servlet. I think, but unfortunately I have a terrible teacher
to the servlet and if the user id is correct then a new page will be displayed with his... pass to the servlet and all the fields brlongs to that id will be appear... will be done by using jsp and servlet... Plz help me,im really tensed...........  
servlet  hi sir,this is ashok.i installed tomcat 6.0 and jdk-150.i checked the server it's working but when execute servlet program for the .class file it shows the errors javax.servlet is not exist.what can i do,please tell me