Escolar Documentos
Profissional Documentos
Cultura Documentos
What is a servlet? Servlets are modules that extend request/response-oriented servers,such as Java-enabled web servers. For example, a servlet might be responsible for taking data in an HTML order-entry form and applying the business logic used to update a companys order database. Servlets are to servers what applets are to browsers. Unlike applets, however, servlets have no graphical user interface. Whats the advantages using servlets over using CGI? Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. Servlets also address the problem of doing server-side programming with platform-specific APIs: they are developed with the Java Servlet API, a standard Java extension. What are the general advantages and selling points of Servlets? A servlet can handle multiple requests concurrently, and synchronize requests. This allows servlets to support systems such as online real-time conferencing. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers that mirror the same content, and to partition a single logical service over several servers, according to task type or organizational boundaries. Which package provides interfaces and classes for writing servlets? javax Whats the Servlet Interface? The central abstraction in the Servlet API is the Servlet interface. All servlets implement this interface, either directly or, more commonly, by extending a class that implements it such as HttpServlet.Servlets > Generic Servlet > HttpServlet > MyServlet. The Servlet interface declares, but does not implement, methods that manage the servlet and its communications with clients. Servlet writers provide some or all of these methods when developing a servlet. When a servlet accepts a call from a client, it receives two objects. What are they? ServletRequest (which encapsulates the communication from the client to the server) and ServletResponse (which encapsulates the communication from the servlet back to the client). ServletRequest and ServletResponse are interfaces defined inside javax.servlet package. What information does ServletRequest allow access to? Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received it. Also the input stream, as ServletInputStream.Servlets use the input stream to get data from clients that use application protocols such as the HTTP POST and GET methods. What type of constraints can ServletResponse interface set on the client? It can set the content length and MIME type of the reply. It also provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data. Explain servlet lifecycle? Each servlet has the same life cycle: first, the server loads and initializes the servlet (init()), then the servlet handles zero or more client requests (service()), after that the server removes the servlet (destroy()). Worth noting that the last step on some servers is done when they shut down. How does HTTP Servlet handle client requests? An HTTP Servlet handles client requests through its service method. The service method supports
2.
3.
4. 5.
6.
7.
8.
9.
10.
standard HTTP client requests by dispatching each request to a method designed to handle that request.
What is the servlet? Servlet is a script, which resides and executes on server side, to create dynamic HTML. In servlet programming we will use java language. A servlet can handle multiple requests concurrently What is the architechture of servlet package? Servlet Interface is the central abstraction. All servlets implements this Servlet Interface either directly or indirectly (may implement or extend Servlet Interfaces sub classes or sub interfaces) Servlet | Generic Servlet | HttpServlet ( Class ) we will extend this class to handle GET / PUT HTTP requests | MyServlet What is the difference between HttpServlet and GenericServlet? A GenericServlet has a service() method to handle requests.HttpServlet extends GenericServlet added new methods doGet() doPost() doHead() doPut() doOptions() doDelete() doTrace() methods Both these classes are abstract. Whats the difference between servlets and applets? Servlets executes on Servers. Applets executes on browser. Unlike applets, however, servlets have no graphical user interface. What are the uses of Servlets? A servlet can handle multiple requests concurrently, and can synchronize requests. Servlets can forward requests to other servers and servlets. Thus servlets can be used to balance load among several servers. When doGET() method will going to execute? When we specified method=GET in HTML Example : < form name='SSS' method='GET'> When doPOST() method will going to execute? When we specified method=POST in HTML < form name='SSS' method='POST' >
What is the difference between Difference between doGet() and doPost()? GET Method : Using get method we can able to pass 2K data from HTML All data we are passing to Server will be displayed in URL (request string). POST Method : In this method we does not have any size limitation. All data passed to server will be hidden, User cannot able to see this info on the browser. What is the servlet life cycle? When first request came in for the servlet , Server will invoke init() method of the servlet. There after if any user request the servlet program, Server will directly executes the service() method. When Server want to remove the servlet from pool, then it will execute the destroy() method Which code line must be set before any of the lines that use the PrintWriter? setContentType() method must be set. Which protocol will be used by browser and servlet to communicate? HTTP In how many ways we can track the sessions? Method 1) By URL rewriting Method 2) Using Session object Getting Session form HttpServletRequest object HttpSession session = request.getSession(true); Get a Value from the session session.getValue(session.getId()); Adding values to session cart = new Cart(); session.putValue(session.getId(), cart); At the end of the session, we can inactivate the session by using the following command session.invalidate(); Method 3) Using cookies Method 4) Using hidden fields How Can You invoke other web resources (or other servelt / jsp ) ? Servelt can invoke other Web resources in two ways: indirect and direct. Indirect Way : Servlet will return the resultant HTML to the browser which will point to another Servlet (Web resource) Direct Way : We can call another Web resource (Servelt / Jsp) from Servelt program itself, by using RequestDispatcher object.
You can get this object using getRequestDispatcher(URL) method. You can get this object from either a request or a Context. Example : RequestDispatcher dispatcher = request.getRequestDispatcher(/jspsample.jsp); if (dispatcher != null) dispatcher.forward(request, response); } How Can you include other Resources in the Response? Using include method of a RequestDispatcher object. Included WebComponent (Servlet / Jsp) cannot set headers or call any method (for example, setCookie) that affects the headers of the response. Example : RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(/banner);  if (dispatcher != null)  dispatcher.include(request, response); } What is the difference between the getRequestDispatcher(String path) ServletRequest interface and ServletContext interface? The getRequestDispatcher(String path) method of ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a / it is interpreted as relative to the current context root. The getRequestDispatcher(String path) method of ServletContext interface cannot accepts relative paths. All path must sart with a / and are interpreted as relative to curent context root. If the resource is not available, or if the server has not implemented a RequestDispatcher object for that type of resource, getRequestDispatcher will return null. Your servlet should be prepared to deal with this condition. What is the use of ServletContext? Using ServletContext, We can access data from its environment. Servlet context is common to all Servlets so all Servlets share the information through ServeltContext. Is there any way to generate PDFS dynamically in servlets? We need to use iText. A open source library for java. Please refer sourceforge site for sample servlet examples. What is the difference between using getSession(true) and getSession(false) methods? getSession(true) - This method will check whether already a session is existing for the user. If a session is existing, it will return that session object, Otherwise it will create new session object and return taht object. getSession(false) - This method will check existence of session. If session exists, then it returns the reference of that session object, if not, this methods will return null.
Explain the life cycle methods of a Servlet. A: The javax.servlet.Servlet interface defines the three methods known as lifecycle method. public void init(ServletConfig config) throws ServletException public void service( ServletRequest req, ServletResponse res) throws ServletException, IOException public void destroy() First the servlet is constructed, then initialized wih the init() method. Any request from client are handled initially by the service() method before delegating to the doXxx() methods in the case of HttpServlet. The servlet is removed from service, destroyed with the destroy() methid, then garbaged collected and finalized.
TOP
Q:What is the difference between the getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface and javax.servlet.ServletContext interface? A: The getRequestDispatcher(String path) method of javax.servlet.ServletRequest interface accepts parameter the path to the resource to be included or forwarded to, which can be relative to the request of the calling servlet. If the path begins with a "/" it is interpreted as relative to the current context root. The getRequestDispatcher(String path) method of javax.servlet.ServletContext interface cannot accepts relative paths. All path must sart with a "/" and are interpreted as relative to curent context root.
TOP
Q:Explain the directory structure of a web application. A: The directory structure of a web application consists of two parts. A private directory called WEB-INF A public resource directory which contains public resource folder. WEB-INF folder consists of 1. web.xml 2. classes directory 3. lib directory
TOP
Q:What are the common mechanisms used for session tracking? A: Cookies SSL sessions URL- rewriting
TOP
Q:Explain ServletContext. A: ServletContext interface is a window for a servlet to view it's environment. A servlet can use this interface to get information such as initialization parameters for the web applicationor servlet container's version. Every web application has one and only one ServletContext and is accessible to all active resource of that
application.
TOP
Q:What is preinitialization of a servlet? A: A container doesnot initialize the servlets ass soon as it starts up, it initializes a servlet when it receives a request for that servlet first time. This is called lazy loading. The servlet specification defines the <load-on-startup> element, which can be specified in the deployment descriptor to make the servlet container load and initialize the servlet as soon as it starts up. The process of loading a servlet before any request comes in is called preloading or preinitializing a servlet. TOP [ Received from Amit Bhoir ] Q:What is the difference between Difference between doGet() and doPost()? A: A doGet() method is limited with 2k of data to be sent, and doPost() method doesn't have this limitation. A request string for doGet() looks like the following: http://www.allapplabs.com/svt1?p1=v1&p2=v2&...&pN=vN doPost() method call doesn't need a long text tail after a servlet name in a request. All parameters are stored in a request itself, not in a request string, and it's impossible to guess the data transmitted to a servlet only looking at a request string. TOP [ Received from Amit Bhoir ] Q:What is the difference between HttpServlet and GenericServlet? A: A GenericServlet has a service() method aimed to handle requests. HttpServlet extends GenericServlet and adds support for doGet(), doPost(), doHead() methods (HTTP 1.0) plus doPut(), doOptions(), doDelete(), doTrace() methods (HTTP 1.1). Both these classes are abstract. TOP [ Received from Amit Bhoir ] Q:What is the difference between ServletContext and ServletConfig? A: ServletContext: Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.The ServletContext object is contained within the ServletConfig object, which the Web server provides the servlet when the servlet is initialized ServletConfig: The object created after a servlet is instantiated and its default constructor is read. It is created to pass initialization information to the servlet.
Controller Functions
Describe the functions of Controller? Latest Answer: Controller as the name specifies is a part of the application server that controlles the whole application.In MVC(if you are aware of model,view,controller) the maintasks of the controller are:1> Take the user inputs from the request and understand what ...
Read Answers (1) | Asked by : desh12345 Answer Question Subscribe
_jspService() Method
Why do we use underscore(_) symbol only with jspService() method? Latest Answer: Any methods are not be overriden by end users are typically written starting with '-'. _jspService method is not also be overriden by end users.Container invoke this method for each request, passing the request and response object. ...
Read Answers (5) | Asked by : kirankumarg Answer Question Subscribe
Response for the Servlet, calls the appropriate servlet service method (doGet or doPost) to service ...
Read Answers (1) | Asked by : khadarzone Answer Question Subscribe
Servlet container
what is difference between servlet container and servlet config? Latest Answer: servlet container is part of web server which provides run time environment for servlets i.e it manages the entaire life cycle for the servlets like it creates instance,initialization,processing and destroying it. ...
Read Answers (2) | Asked by : gopalraop Answer Question Subscribe
Servlets Questions
1)What is web.xml?2)what is the filter?3)How to we create a new JSTL class?4)When we are developing the project which collections mostly used?5)Difference between reqeust.getAttribute,and request.getParameter? Latest Answer: 1)What is web.xml?web.xml is nothing but a deployment descriptor. It describes a web applicants deployment settings.2)what is the filter?It is an Pluggable web componenet device it allow us to implement or add pre processing or post processing logic ...
Read Answers (1) | Asked by : Ramu Answer Question Subscribe
ServletContainer. ...
What is the difference between doGet methods,doGet()and service() used in servlet?can we use service()
What is the difference between doGet methods,doGet()and service() used in servlet?can we use service() methods replace of doGet() and doPost()?
Read Answers (7) | Asked by : ajay Answer Question Subscribe
Why do we need to implement 3rd party support for using connection pooling ?
View Question | Asked by : JavaPassion Answer Question Subscribe
(1) public void service(ServletRequest req,ServletResponce res);(2) protected void service(HttpServletRequest req,HttpServletResponce res);Thus the the modifier for ...
Read Answers (6) | Asked by : sujatham Answer Question Subscribe
where the buisness logic is implemented and depending on the request a response object is generated which is sent back to the client.A Servlet container is that portion of ...
Read Answers (7) | Asked by : sujatham Answer Question Subscribe
javax.servlet.servlet
->Interface
Answer Question
...
Subscribe
Why and when do we use connection pool management system instead of database?
Latest Answer: Connection Pooling is like u have created a set of connection pools and hav stored
them in some data structure.The benefit which u get by doing this is everytime u get a new request u can use one of the available connections u don need to establish a ...
Read Answers (6) | Asked by : kiranmaye Answer Question Subscribe
What is the need for having HTTPServlet class when we already have GenericServlet class which can handle
What is the need for having HTTPServlet class when we already have GenericServlet class which can handle all type of requests?
How many Request, Response & session instance you can create for N number of uesr request from a. user
How many Request, Response & session instance you can create for N number of uesr request from a. user request from same userb. user request from diffrent user
Read Answers (2) | Asked by : nitin j Answer Question Subscribe
the same servlet container or in other container .When we are using request dispatch method ,we can forward the request only to a servlet that is in the current container. ...
Read Answers (1) | Asked by : hemraj Answer Question Subscribe
//logic
Subscribe
How to call the resource that is available in another web server by using response.sendRedirect()?
Latest Answer: Using this method is pretty straight-forward. BUt there is a simple catch: No data
should be committed to the servlet output stream before the redirection occurs.In case data has been committed and then redirection is forced, an IllegalStateException ...
Read Answers (2) | Asked by : rajesh Answer Question Subscribe
that. It allows you to create dynamic web applications as opposed to the static HTML. ...
Read Answers (2) | Asked by : nirupama Answer Question Subscribe
time will execute in a given servlet instances service method. It is important to note that this guarantee only applies to each servlet instance, since the container may ...
Read Answers (4) | Asked by : Raviranjan Kumar Sinha Answer Question Subscribe
Explain about Inter-Servlet communication and business reason for using Inter-Servlet communication
Explain about Inter-Servlet communication and business reason for using Inter-Servlet communication
Read Answers (1) | Asked by : Ramesh Answer Question Subscribe
implemented by the GenericServlet class. The implementation of this init method in the GenericServlet just stores the ServletConfig object in some private variable ...
Read Answers (1) | Asked by : jayalakshmic Answer Question Subscribe
What is the difference between Single Thread Model and Multi Thread Model? In which situation we use
What is the difference between Single Thread Model and Multi Thread Model?In which situation we use the Single Threaded Model?
Read Answers (1) | Asked by : madhu Answer Question Subscribe
Where session information gets stored in methods like Cookies, URLRewriting etc.
Latest Answer: In cookies, Session information is stored at client side in a folder called cookie, if
the browser is set to cookie disable mode then this approach will not work.In URL rewriting, it is stored within each URL & attached with header. Except then cookies ...
Read Answers (1) | Asked by : krishna Ballabh Answer Question Subscribe
well.All requests that will come for the SingleThreadModel resource would be available only for one user at a time. ...
Read Answers (3) | Asked by : guptakcsg Answer Question Subscribe
stored and 20 cookies per url and 300 users information can store. Every time server set the cookie it has to check whether it got stored or not by accessing the cookie with ...
Read Answers (1) | Asked by : dile_sahoo Answer Question Subscribe
single JVM, objects are always passed by reference.When it comes to distributed, which means 2 JVMs running either on the same or different machines, objects are passed by ...
Read Answers (1) | Asked by : enjoy Answer Question Subscribe
Latest Answer: 20 cookies for per website and 300 cookies per uniqe user, also they can limit
communication (HTTP) and create a sub-protocol within it to perform specific tasks. ...
Read Answers (1) | Asked by : gothlururaaja Answer Question Subscribe
the dynamic part of the application from the static part and for that the dynamic part given the name "view" is handled as JSP's . while the static part as controller ...
Read Answers (6) | Asked by : Prabhakaran Answer Question Subscribe
In MVC1 architecture there is no controller concept then why it is called as MVC architecture?
Latest Answer: There is MVC means Model, View & Controller, There is no MVC1 & MVC2, There is
cycle methods, so container only call these methods....If u written init() inside destor() but destoy() method can not works. ...
Read Answers (9) | Asked by : sarithareddy Answer Question Subscribe
use thelife-cycle methods of the servlet and also the server needs to make sure that all the life cycle methods of the servlets have to be implemented.So if a class is extending ...
Read Answers (8) | Asked by : Saurabh Tags : Abstract Answer Question Subscribe
runtime.Depending on the request which a user is sending we get a respose which is dependent on the request and it is not fixed.For example when a user enters his user name and password on ...
Read Answers (4) | Asked by : radhika Answer Question Subscribe
How many hits can Apache tomcat take at a time i.e How many requests it accept at a time.
Latest Answer: Apache tomcat testing version can handle only 50 request at a time. ... Read Answers (2) | Asked by : ashu Answer Question Subscribe
Can we put costructor in place of init() method . if yes how it works plz xplain in detail??
Latest Answer: webcontainer create an object for servlet class.for createing an object use the
newInstance() method.this object automaticaly create a defaultconstructor so we can not create parametarised constructior for this object.praveen kumar sakhamudi ...
Read Answers (5) | Asked by : ashish Answer Question Subscribe
What is the difference between doGet() and doPost() methods of a HttpServlet and when to use each one?
What is the difference between doGet() and doPost() methods of a HttpServlet and when to use each one?
Read Answers (11) | Asked by : rs Answer Question Subscribe
When to use session scope1?How session object is managed by the webcontainer?When the session object
When to use session scope1?How session object is managed by the webcontainer?When the session object is created and when it is removed?
What is difference between HttpServlet and GenericServlet. and when to use and why. what is the importance
What is difference between HttpServlet and GenericServlet. and when to use and why. what is the importance of each.
Read Answers (6) | Asked by : Enayat Answer Question Subscribe
What factors effects on selecting a technology. In deatail, A customer came with SRS, how to select
What factors effects on selecting a technology. In deatail, A customer came with SRS, how to select a technology (java,.net,c,c++) to develop a application?
Read Answers (1) | Asked by : Aruna Answer Question Subscribe
class but as we know taht it is not in our hands to make the instaniate a servlet so cannot use that class level variable by instaniating ...
Read Answers (1) | Asked by : Raj
Answer Question
Subscribe
three methods .Those methods are init(ServletConfig config) service(ServletRequest req,ServletResponse res) ...
Read Answers (2) | Asked by : Ferdousi Answer Question Subscribe
Can anyone briefly explain mvc1 and mvc2 and differences and which is best.
Latest Answer: MVC Describes that each part of responsibiltiesM-Model is responsible for business
process and business dataV-view is responsible for response content to dispatch the clientCController is responsible for to control the requset and response In MVC1, Model ...
Read Answers (8) | Asked by : pbv_krishnamraju Answer Question Subscribe
requestdispatcher.forward and response.sendredirect? The response will not be sent back to the client and so the client will not know about this change of resource on the server. for ...
Read Answers (5) | Asked by : Navya Answer Question Subscribe
the entity body at the location specified by the URI. It is similar to the PUT function in FTP.doDELETE: The DELETE method is used to delete a document from the server. The document ...
Read Answers (2) | Asked by : mail_2_mahendran Answer Question Subscribe
How many objects are created when same or different client send 100 requests to a servlet?
Latest Answer: If the servlet implements SingleThreadModel interface then many instances of
that servlet can be created by the Container otherwise,(i) If the web application is a distributed webapplication then each JVM will have only one servlet instance no matter ...
Read Answers (10) | Asked by : sadashivarao Answer Question Subscribe
stop you. But you shouldnt. The original reason for init() was that ancient versions of Java couldnt dynamically invoke constructors with arguments, so there was no way ...
Read Answers (7) | Asked by : Abhijit Datta Answer Question Subscribe
Can a webcontainer creates another cookie eventhough we r set the maxage of already created cookie
Can a webcontainer creates another cookie eventhough we r set the maxage of already created cookie while sending second request within period of setmaxage of that cookie
If we put some request, intially either doget() or dopost() is getting invoked? why not any servlet
If we put some request, intially either doget() or dopost() is getting invoked? why not any servlet life cycle method is not getting invoked?Then why don't we include this doget() and dopost() in the servlet life cycle methods?
Read Answers (7) | Asked by : Roshini Answer Question Subscribe
While using cookies, when the browser is shut down. will the data be available at next open of browser.
While using cookies, when the browser is shut down. will the data be available at next open of browser. If not available, how to over come that.
Read Answers (5) | Asked by : Srini99 Answer Question Subscribe
When destroy method get call, will it call for each user please give the ans in detail?
Latest Answer: 1)when the application is stopped2)when a class is replaced with the new
response object and creates the servlet instance.After it calls the servlet life cycles methods like init().After completing the intialization it calls the service()method passing ...
Read Answers (4) | Asked by : ram Answer Question Subscribe
How can a web container know whether cookies are accepted or not accepted by the browser
Latest Answer: The only way to know for sure is to set a cookie on a response, and see ifit comes
back on the following request. You have absolutely no clue fromlooking just at the current request. Just as an example, I run Netscape6, configured to warn ...
Read Answers (1) | Asked by : venkat
Answer Question
Subscribe
content.Because most of the web applications are dynamic in nature .In order to generate the dyanmic content we are using the servlets. ...
Read Answers (8) | Asked by : padmakalyani Answer Question Subscribe
you are perfectly right in your explanation. but there is a small mistake in your writting. the refresh header is not a part of request header rather it is a header of response. response.setHeader("Refresh","300; ...
Read Answers (3) | Asked by : sadashivarao Answer Question Subscribe
used servletconfig and u cant passed argument constructor b'coz only first time yr constructor has called and for other request directlly service method called so we cant able to ...
Read Answers (4) | Asked by : javadeep Answer Question Subscribe
Hi Guys, Can we write destroy() method in the init() method of a Servelt. if we can, what will happen?
Hi Guys, Can we write destroy() method in the init() method of a Servelt. if we can, what will happen? if we cant , why we cant?with regards, santh
The servlet communication when they are running in different servlet container. sOne and sTwo are two servlets, here can we include sTwo's output in response of sOne's?Thank ...
Read Answers (4) | Asked by : sudhakar_bvr Answer Question Subscribe
Which method is more advantageous doGET() or doPOST()? in which situation does we use doGET() then?
Latest Answer: doGET() is better ... Read Answers (6) | Asked by : neelima Answer Question Subscribe
Latest Answer: Use can store variables in session, but u can store it in object form only.if it is
primitive type u can use wrapper classes to convert it into object.session.setAttribute("test","xyzp");Stringstr=(String)session.getAttribute("test");while retrieving ...
Read Answers (1) | Asked by : Sandy Answer Question Subscribe
jar files a. commons-dbcp-1.2.jar b. commons-collections-3.1.jar c. commons-pool-1.3.jar 2. we want to add an entry in server.xml of the tomcat factory org.apache.commons.dbcp.BasicDataSourceFactory driverClassName oracle.jdbc.OracleDriver url jdbc:oracle:thin:@localhost:1521:orcl username anand password pass maxActive 20 maxIdle 10 maxWait -1 for ...
Read Answers (2) | Asked by : rama krishna Answer Question Subscribe
Suppose there are 15 links on the homepage of a site and each link creates a new request, how your servlet
Suppose there are 15 links on the homepage of a site and each link creates a new request, how your servlet controller would handle it? (Assuming you are using MVC-2)
Read Answers (3) | Asked by : Anoop Answer Question Subscribe
secondservlet executing following sequence of methodinit()service()destroy()so the 1st time request to servlet, response time is high than 2nd request so to avoid ...
Read Answers (2) | Asked by : adepu Answer Question Subscribe
I am really happy after saw your answer.It is the perfect and Suitable answers.Thanks & Regards,Nagaraju. ...
Read Answers (3) | Asked by : Rupesh Answer Question Subscribe
Suppose number of servlets/jsps from various web applications want to access shared data, what is the
Suppose number of servlets/jsps from various web applications want to access shared data, what is the mechanism to achieve the same?
Read Answers (9) | Asked by : hmashruf Answer Question Subscribe
What will happen when we call the destroy method in the init method? will the servlet exist?
Latest Answer: Hi,The servlet specifications clearly states that we can not explicity destroy the
servlet instance by coding what so ever in destroy method.We can only perform clean up operations.So, if we call the service method in init, it will be called and Say I ...
Read Answers (6) | Asked by : Yogesh Answer Question Subscribe
Can we override the service method?if we can do that then why do we override only doGET()and doPost()
Can we override the service method?if we can do that then why do we override only doGET()and doPost() methods if the servlet is of protocol specific?
Read Answers (5) | Asked by : anandkolam Answer Question Subscribe
.the main drawback of cgi is1. starting process is very expensive2. it performs very poor. ...
Read Answers (5) | Asked by : venkata narayana Answer Question Subscribe
What are the types of refrences available in java. How they work
Latest Answer: hi,I apprciate ur answer,if u know jsp then tell me in jsp if there is include
directive element then why they have provided include action element. ...
Read Answers (3) | Asked by : Asif Answer Question Subscribe
What is differents between forword(),include() and sendRedirect()? In which circumtances all are used?
What is differents between forword(),include() and sendRedirect()? In which circumtances all are used? Give Proper Examles.
Read Answers (4) | Asked by : shivam_it3 Answer Question Subscribe
of strings. "String represent fixed length immutable character sequences" Where as "String Buffer Represent grow able and writeable character sequences" all string ...
Read Answers (4) | Asked by : roja Answer Question Subscribe
What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest
What is the difference betweem getRequestDispatcher() available as part of ServletContext and ServletRequest
Read Answers (10) | Asked by : divya_a Answer Question Subscribe
Can we write bussiness methods in servlets? if yes, then how can u access that from out side of the
Can we write bussiness methods in servlets? if yes, then how can u access that from out side of the servlets?
Read Answers (4) | Asked by : sivasivasiva Answer Question Subscribe
information from one page to another page. we can manage sessions in two ways using cookies using URL rewriting ...
Read Answers (5) | Asked by : karthik Answer Question Subscribe
How to count how many times aprticular link has been clicked using jsp and javascript
Latest Answer: Hi, Clearly, it depends on the level of details one needs to capture, let's say
XYZ123.com wants to place a promotional ad on a frequently visited page.For simplicity, let's confine to one particular page (say XYZPage.jsp):(a) How many times users visit ...
Read Answers (4) | Asked by : payal kalra Answer Question Subscribe
I can do every thing using jsp itself,then what is the need of using servlet?in which situation ,we
I can do every thing using jsp itself,then what is the need of using servlet?in which situation ,we must use servlet with jsp?
Read Answers (1) | Asked by : Ganesh Answer Question Subscribe
Whats the difference between using invalidate() & sessionDestroyed for sessionclosing.
Latest Answer: session's invalidate method is used when the session will no longer exist or when
for a particular client is leaving the session Eg:during the logout.sessiondestroyed is a method of HttpSessionListener ,and this is called when the session is being ...
Read Answers (1) | Asked by : Shekhar Answer Question Subscribe
body..http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/Servlet.htmlpublic void destroy()Called by the servlet container to indicate to a servlet that the servlet is ...
Read Answers (10) | Asked by : nagaraj Answer Question Subscribe
Latest Answer: the ResultSet is closed as soon as the Statement itself is closed, or used to
retrieve another ResultSet. Therefore, the pointer that once provided a handle to the query results is no longer valid, and this is where CachedRowSet comes in. Unlike a ResultSet, ...
Read Answers (2) | Asked by : divya_a Answer Question Subscribe
What is default capacity of connection pool objects in pool of app-server Weblogic and Tomcat webserver?
What is default capacity of connection pool objects in pool of app-server Weblogic and Tomcatwebserver?
Read Answers (4) | Asked by : srikanth.sunjava Answer Question Subscribe
In normal javabean, bean object is serailizable,and Connectuin object is transient object.Then How we
In normal javabean, bean object is serailizable,and Connectuin object is transient object.Then How we using javabean for communnication between Servlet and JSP for data Transfer?
Read Answers (1) | Asked by : srikanth.sunjava Answer Question Subscribe
How can I retrive only IntegerObjects from a vector in which I stored all types of objects
Latest Answer: The example code may help you out.Vector v =
getDataVector();//getDataVector() may be some method where you will put all your objects into vector.int size = v.size();for(int i = 0 ; i
Read Answers (1) | Asked by : Eswar Rao Answer Question Subscribe
Consider a scenario where 2 instances of an appserver are running in a machine. And one application
Consider a scenario where 2 instances of an appserver are running in a machine. And one application has been deployed in the two servers. Does these two applications deployed in two servers use the same JVM or different?
Read Answers (3) | Asked by : Sohamsri Answer Question Subscribe
Consider a scenario in which 4 users are accessing a servlet instance. Among which one user called
Consider a scenario in which 4 users are accessing a servlet instance. Among which one user called destroy() method. What happens to the rest 3 users?
Read Answers (4) | Asked by : Sohamsri Answer Question Subscribe
the information in sruts-config.xml and get the error page file.In struts-config.xml ...
processor intensive. If you don't have a high-powered computer running your web server and you expect to have a lot of traffic, you might want to limit the number of documents ...
What is session tracking ?state the uses of GET and POST request to handle Http request ?
Latest Answer: Session tracking is done to maintain the state, as HTTP is an
stateless protocol.Session tracking can be done in following ways - 1. Cookies.2. Hidden variables.3. URL rewriting.When you use GET, then the data appears in the querystring of the web browser ...
Read Answers (2) | Asked by : kevin uttankar Answer Question Subscribe
process for each client request but servlet technology just creates a thread. ...
Read Answers (1) | Asked by : Devika Bhatt Answer Question Subscribe
AnywhereTM philosophy of the JavaTM architecture. Instead of being tied to a single platform or vendor,JSP technology can run on any Web server and is supported by a wide variety ...
Read Answers (2) | Asked by : Devika Bhatt Answer Question Subscribe
explicitly but internally it uses multi threading plz give me the response ...
Read Answers (7) | Asked by : shanthini Answer Question Subscribe
How do to prevent user by viewing secured page by clicking back button when session expired..:)
Latest Answer: You will need to set the appropriate HTTP header attributes to prevent the
dynamic content output by the JSP page from being cached by the browser. Just execute the following scriptlet at the beginning of your JSP pages to prevent them from being cached ...
Read Answers (1) | Asked by : atqpx Answer Question Subscribe
What is default Session time out in the servers like Tomcat, Weblogic, JBoss,..etc?
Latest Answer: 30 minute ... Read Answers (6) | Asked by : sumanth Answer Question Subscribe
How can a servlet automatically updated by its data without refreshing?take one example of one sensex
How can a servlet automatically updated by its data without refreshing?take one example of one sensex site. the corresponding data are shown in a scrolling manner. how they can automatically be refreshed after some time. without refreshing the page.
In servlets, what is the use of sendredirect(),include( ), forward() ?and in applecation level at what
In servlets, what is the use of sendredirect(),include( ), forward() ?and in applecation level at what scnario they will be used i know only that send redircet is of client side. and remaing are severside functions
Read Answers (3) | Asked by : srikanth Answer Question Subscribe
using this method we get values of init parameter and context parameter.ex:for suppose in web.xml we configurelike thisaaaAAAAAget ...
Read Answers (4) | Asked by : raj Answer Question Subscribe
How to get value from init() method in servlet? orhow to get initializaion time values from init() in
How to get value from init() method in servlet? orhow to get initializaion time values from init() in servlet? plz ans !!!!!!!!!!!!!!!!!!!
Read Answers (12) | Asked by : raj Answer Question Subscribe
How we can check in particular page the session will be alive or not?
Latest Answer: use this methodHttpSession session=request.getSession(false);in this case the
web container checks JSessionID is available on behalf of client or not.if session is alive it sends old session id.if session is not available it returns null ...
Read Answers (5) | Asked by : chandu Answer Question Subscribe
shared between the servlets as : One servlet puts the data in a well known place,which acts as a container and other servlets access the data from that place.These well known ...
Read Answers (9) | Asked by : kailash Answer Question Subscribe
Suppose in web.xml file we are given 30 and in the servlet program we are given setSessionInActiveInterval(40).when
Suppose in web.xml file we are given 30 and in the servlet program we are given setSessionInActiveInterval(40).when that session will be terminated ? After 30 sec or 40 sec?
Read Answers (1) | Asked by : padmaja Answer Question Subscribe
lets say RAM is 128 MB and on booting the system say 28 MB is used By Operating System or other services, then u can store up to 100 mb of data in sessionCheers ...
Read Answers (4) | Asked by : padmaja Answer Question Subscribe
Ex,
Actually, jsp must have a attributes, and its can be setted as well as getted. session.setattribute (" "); request.setattribute(" ...
Answer Question Subscribe
I want to know how to encode textbox in servlet so we find complete column information from the database
I want to know how to encode textbox in servlet so we find complete column information from the database
ypes of Servlets?
Latest Answer: Servlets are mainly of two types 1. Genric servlet 2. http servlet Rest all servlet
javasoft people already defined in genericclass,http etc like as we wish to create infinate no of servlets can be created with implements Servlet. ...
Read Answers (2) | Asked by : chandu Answer Question Subscribe
How will u pass the argument from one servlet to another servlet?
Latest Answer: we can use forward and include of requset dispatcher and the arguments would
We have two applications in that we have two servlets each.How they(servlets) communicate with each
We have two applications in that we have two servlets each.How they(servlets) communicate with each other ?
Read Answers (8) | Asked by : chandu Answer Question Subscribe
interface. It has been implemented by the GenericServlet class. The implementation of this init method in the GenericServlet just stores the ServletConfig object in some ...
Read Answers (6) | Asked by : javavikas Answer Question Subscribe
characters upto 400 bytes , we can use GET. If it exceeds that limit we can go for POST. Any number of bytes can be sent over the net as name and value pair and bundled with ...
Read Answers (2) | Asked by : chandu Answer Question Subscribe
1st of all doGet() or doPost() will be called then internally it will call to protected service() method and it will generate the response. ...
Read Answers (6) | Asked by : chandu Answer Question Subscribe
init() throws Exception(){//do something}then webcontainer search for the init method to call n it find this in our servlet and didnt provide all the things ...
Read Answers (6) | Asked by : chandu Answer Question Subscribe
How the server will know (i.e) when it can invoke init, service,destroy methods of servlet life cycle?
How the server will know (i.e) when it can invoke init, service,destroy methods of servlet life cycle?
Read Answers (3) | Asked by : chandu Answer Question Subscribe
Internet and automatically installed on client machine , runs as a part of a web document or web page.So that means applet also controlled by a server called Internt ...
Read Answers (23) | Asked by : Nilesh Answer Question Subscribe
How many ServletConfig and servlet context objects are present in one application?
Latest Answer: The answers above are not fully correct. The correct answer is1. There is
a servlet configper servlet in an application. (Almost, all got this right)2. There is one ServletContext, per application and per jvm. Per jvm is the missing piece. Its about ...
Read Answers (5) | Asked by : satyasudheer Answer Question Subscribe
constructor private so that no other class can user the new() keyword to create the instance of the singleton class. It will provide a public method which will create or return ...
Read Answers (12) Answer Question Subscribe
Servlet is Java class. Then why there is no constructor in Servlet ? Can we write the constructor
Servlet is Java class. Then why there is no constructor in Servlet ? Can we write the constructor in Servlet
Read Answers (6) Answer Question Subscribe
After converting jsp into servlet which methods are present i.e all 6 methods(jspinit(),_jspService(),jspDestroy(),init(),service(),destroy())
After converting jsp into servlet which methods are present i.e all 6 methods(jspinit(),_jspService(),jspDestroy(),init(),service(),destroy()) or only 3 methods i.e either jsp life cycle methods or servlet lifecycle methods
Read Answers (3) Answer Question Subscribe
view oart we can add JSP other wise both can do the sane thing but in larger projects the servlet code becomes cluttred ...
Read Answers (3) Answer Question Subscribe
request, it responds with an HTTP response, such as sending back an HTML page. To process a request, a Web server may respond with a static HTML page or image, send a redirect, ...
Read Answers (5) Answer Question Subscribe
If you want a servlet to take the same action for both GET and POST request, what should you do?
Simply have doGet call doPost, or vice versa. Latest Answer: in addition to what veeru mentioned, we can override the service(HttpServletRequest , HttpServletResponse ) method as well. service method takes priority over doGet() and/or doPost(). ...
Read Answers (2) Answer Question Subscribe
What are the differences between GET and POST service methods?
A GET request is a request to get a resource from the server. Choosing GET as the "method" will append all of the data to the URL and it will show up in the URL bar of your browser. The amount Latest Answer: 1) Get is Faster than Post..2) Get Is Idempotent i.e same work can be done again and again without harming database...3) Amount of data send is limited to few characters only and are visible in address bar, so sensitive data cannot be sent via GET. ...
Read Answers (14) Answer Question Subscribe
Operations performed on vector are either posing a value into the vector (or) retriving a value from
Operations performed on vector are either posing a value into the vector (or) retriving a value from the vector . which operation is synchronized
Read Answers (3)
Answer Question
Subscribe
When we increase the buffer size in our project using page directive attribute 'buffer' what
When we increase the buffer size in our project using page directive attribute 'buffer' what changes we observe?
Read Answers (1) Answer Question Subscribe
What is difference between sendRedirect() and forward()..? Which one is faster then other and which
What is difference between sendRedirect() and forward()..? Which one is faster then other and which works on server?
Read Answers (9) Answer Question Subscribe
What is a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or
What is a better approach for enabling thread-safe servlets and JSPs? SingleThreadModel Interface or Synchronization? Although the SingleThreadModel technique is easy to use, and works well for low volume sites, it does not scale well. If you anticipate your users to increase in the future, you may be better off implementing
Read Answers (1) Answer Question Subscribe
ServletContext that i have come across is that it can be used to hold the object which can generate request independent and non-static data. Suppose we want that our servlet should ...
Read Answers (3) Answer Question Subscribe
the difference as a JSP is ultimately converted into a Servlet and run on Server. Basically, its the separation of roles played by JSP and Servlet which is important. In ...
Read Answers (10) Answer Question Subscribe
following code in your applet. //The path of the servlet needs to be passed as input param to URL Class. URL urlObj = new URL(http://server/servlet?var1=1&var2=2); ...
Read Answers (3) Answer Question Subscribe
period.ServletContext is used for thye communication between the servlet and the servletcontainer thatis to give MIME types.ServletContext is used to access other environments thatis ...
Read Answers (3)
Answer Question
Subscribe
outside to the servlet. e.g. JDBC driver classes. ServletConfig is limited to the Servlet only and the ServletContext is spread over the complete web application. So ServletContext ...
Read Answers (2) Answer Question Subscribe
Which code line must be set before any of the lines that use the PrintWriter?
setContentType() method must be set before transmitting the actual document. Latest Answer: response.setContentType("text/hthl"); line before PrintWriter line. ...
Read Answers (2) Answer Question Subscribe
Latest Answer: 1. How do u difine an error page?2.What r the methods called in servlet life
cycle?3.How can u make session variables un available?4. How to change the port no of agiven application server?5.How do udeploye an EJB in the existing application using webspehere? 6.Why ...
Read Answers (4) Answer Question Subscribe
When a servlet accepts a call from a client, it receives two objects. What are they?
ServeltRequest: which encapsulates the communication from the client to the server.ServletResponse: which encapsulates the communication from the servlet back to the client.ServletRequest and ServletResponse Latest Answer: when a request is sent from the browser to a servlet, the servlet object will be created by the webcontainer if we don't provide load-on-startup element.suppose if we provide load-on-startup element the webcontainer creates the servlet object when ...
Read Answers (2) Answer Question Subscribe
What information that the ServletRequest interface allows the servlet access to?
Information such as the names of the parameters passed in by the client, the protocol (scheme) being used by the client, and the names of the remote host that made the request and the server that received Latest Answer: really, a must-know questions for a j2ee programmer ...
Read Answers (1) Answer Question Subscribe
What information that the ServletResponse interface gives the servlet methods for replying to the client?
What information that the ServletResponse interface gives the servlet methods for replying to the client? It Allows the servlet to set the content length and MIME type of the reply. Provides an output stream, ServletOutputStream and a Writer through which the servlet can send the reply data.
Read Answers (2) Answer Question Subscribe
What is Servlet?
A servlet is a Java technology-based Web component, managed by a container called servlet container or servlet engine, that generates dynamic content and interacts with web clients via a request\/response paradigm.
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 server.
What is servlet container?
The servlet container is a part of a Web server or application server that provides the network services over which requests and responses are sent, decodes MIMEbased requests, and formats MIME-based responses. A servlet container also contains and manages servlets through their lifecycle.
When a client request is sent to the servlet container, how does the container choose which servlet to invoke?
The servlet container determines which servlet to invoke based on the configuration of its servlets, and calls it with objects representing the request and response.
If a servlet is not properly initialized, what exception may be thrown?
During initialization or service of a request, the servlet instance can throw an UnavailableException or a ServletException.
Given the request path below, which are context path, servlet path and path info?
/bookstore/education/index.html context path: /bookstore servlet path: /education path info: /index.html
What is filter? Can filter be used as request or response?
A filter is a reusable piece of code that can transform the content of HTTP requests,responses, and header information. Filters do not generally create a response or respond to a request as servlets do, rather they modify or adapt the requests for a resource, and modify or adapt responses from a resource.
When using servlets to build the HTML, you build a DOCTYPE line, why do you do that?
I know all major browsers ignore it even though the HTML 3.2 and 4.0 specifications require it. But building a DOCTYPE line tells HTML validators which version of HTML you are using so they know which specification to check your document against. These validators are valuable debugging services, helping you catch HTML syntax errors.
What is new in ServletRequest interface ? (Servlet 2.4)
The following methods have been added to ServletRequest 2.4 version: public int getRemotePort() public java.lang.String getLocalName() public java.lang.String getLocalAddr() public int getLocalPort()
Request parameter How to find whether a parameter exists in the request object?
1.boolean hasFoo = !(request.getParameter("foo") == null || request.getParameter("foo").equals("")); 2. boolean hasParameter = request.getParameterMap().contains(theParameter); (which works in Servlet 2.3+)
How can I send user authentication information while making URL Connection?
You'll want to use HttpURLConnection.setRequestProperty and set all the appropriate headers to HTTP authorization.
Can we use the constructor, instead of init(), to initialize servlet?
Yes , of course you can use the constructor instead of init(). There's nothing to stop you. But you shouldn't. The original reason for init() was that ancient versions of Java couldn't dynamically invoke constructors with arguments, so there was no way to give the constructur a ServletConfig. That no longer applies, but servlet containers still will only call your no-arg constructor. So you won't have access to a ServletConfig or ServletContext.
How can a servlet refresh automatically if some new data has entered the database?
Using System.exit(1); in try block will not allow finally code to execute.
What mechanisms are used by a Servlet Container to maintain session information?
Cookies, URL rewriting, and HTTPS protocol information are used to maintain session information
Difference between GET and POST
In GET your entire form submission can be encapsulated in one URL, like a hyperlink. query length is limited to 260 characters, not secure, faster, quick and easy. In POST Your name/value pairs inside the body of the HTTP request, which makes for a cleaner URL and imposes no size limitations on the form's output. It is used to send a chunk of data to the server to be processed, more versatile, most secure.
What is session?
The session is an object used by a servlet to track a user's interaction with a Web application across multiple HTTP requests.
What is servlet mapping?
The servlet mapping defines an association between a URL pattern and a servlet. The mapping is used to map requests to servlets.
What is servlet context ?
The servlet context is an object that contains a servlet's view of the Web application within which the servlet is running. Using the context, a servlet can log events, obtain URL references to resources, and set and store attributes that other servlets in the context can use. (answer supplied by Sun's tutorial).
Which interface must be implemented by all servlets?
Servlet interface.
Loaded(by the container for first request or on start up if config file suggests load-on-startup), initialized( using init()), service(service() or doGet() or doPost()..), destroy(destroy()) and unloaded.
When is the servlet instance created in the life cycle of servlet? What is the importance of configuring a servlet?
An instance of servlet is created when the servlet is loaded for the first time in the container. Init() method is used to configure this servlet instance. This method is called only once in the life time of a servlet, hence it makes sense to write all those configuration details about a servlet which are required for the whole life of a servlet in this method.
Yes, but Before calling the destroy() method, the servlet container waits for the remaining threads that are executing the servlets service() method to finish.
What is the difference between callling a RequestDispatcher using ServletRequest and ServletContext?
We can give relative URL when we use ServletRequest and not while using ServletContext.
Why is it that we can't give relative URL's when using ServletContext.getRequestDispatcher() when we can use the same while calling ServletRequest.getRequestDispatcher()?
Since ServletRequest has the current request path to evaluae the relative path while ServletContext does not.