-
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 of information you can send back using a GET is restricted as URLs can only be 1024 characters. A POST request is a request to post (to send) form data to a resource on the server. A POST on the other hand will...
-
Can I stop JSP execution while in the midst of processing a request?
Yes. Preemptive termination of request processing on an error condition is a good way to maximize the throughput of a high-volume JSP engine. The trick (asuming Java is your scripting language) is to use the return statement when you want to terminate further processing. For example, consider:<% if (request.getParameter("foo") != null) {// generate some html or update bean property} else {/* output...
-
How do I mix JSP and SSI #include?
If you're just including raw HTML, use the #include directive as usual inside your .jsp file.<!--#include file="data.inc"-->But it's a little trickier if you want the server to evaluate any JSP code that's inside the included file. If your data.inc file contains jsp code you will have to use <%@ vinclude="data.inc" %> The <!--#include file="data.inc"--> is used for including non-JSP...
-
-
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.
-
What are the uses of Servlets?
A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to support systems such as on-line 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.
-
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.
-
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 are interfaces defined by the javax.servlet package.
-
What are the advantages using servlets than using CGI?
Servlets provide a way to generate dynamic documents that is both easier to write and faster to run. It is efficient, convenient, powerful, portable, secure and inexpensive. Servlets also address the problem of doing server-side programming with platform-specific APIs. They are developed with Java Servlet API, a standard Java extension.
-
What are the steps required in adding a JSP Tag Libraries?
1. Create a TLD file and configure the required class Information.2. Create the Java Implementation Source extending the JSP Tag Lib Class (TagSupport).3. Compile and package it as loosed class file or as a jar under lib folder in Web Archive File for Class loading.4. Place the TLD file under the WEB-INF folder.5. Add reference to the tag library in the web.xml file.
-
-
What does < %= obj.getXXX() %> the following expression get evaluated to ?
This expression gets evaluated to an argument for the println statement in the generated Servlet as follows:out.println( obj.getXXX() ); // Since it becomes an argument here you should not use semicolon in the JSP expression
-
-
-
How do u maintain a Session?
Ans- A session can be created via the getSession () method of HttpServletRequest. An HttpSession object is returned. This object can store set bindings that associated names with objects. This setAttribute (), getAttribute (), getAttributeNames (), and removeAttribute () method of HttpSession manage these bindings. It is important to note that session state is shared among all the servlets that are...
-
-
-
-
-
JSP Interview Questions
Ans