What are context initialization parameters?
Context initialization parameters are defined in the Deployment descriptor an accessible to all the servlets in the application. You can use context initialization parameters to specify the information that is dynamically change. You can also use these to specify the URL of the database.
<param-value>email@example.com</param-value> </context-param> Reply
How can I implement a thread-safe JSP page?
To make your JSPs thread-safe, you hace to implement the SingleThreadModel interface.
This can be done by using page directive with isThreadSafe attribute by setting it to false:
<%@ page isThreadSafe="false" %>
How do I include static files within a JSP page?
We can include static files within a JSP page using the include directive :
< % @ include file="top.html" % >
How many JSP scripting elements are there and what are they?
Types of Scripting Elements
� Expressions :
<%= expression %> :� Evaluated and inserted into the servlet�s output, i.e., results in something like out.print(expression)
� Scriptlets :
<% code %> :� Inserted verbatim into the servlet�s _jspService method (called by
� Declarations :
<%! code %> :- Inserted verbatim into the body of the servlet class, outside of any
� Directive :
<%@ directive %> :- To use "import" statements in JSPs.
What is servlet context ?
Servlet context 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. A servlet context object is one per web application per JVM and this object is shared by all the servlet. You can get and set the Servlet context object. You can use servelt context object in your program by calling directly getServletContext() or getServletConfig().getServletContext().Reply
What is servlet mapping?
Servlet mapping controls how you access a servlet. Servlet mapping specifies the web container of which java servlet should be invoked for a url given by client. For this purpose web container uses the Deployment Decriptor (web.xml) file. Servlets are registered and configured as a part of a Web Application. To register a servlet, you add several entries to the Web Application deployment descriptor.
Servlet Mapping :
A developer can map all the servelts inside its web application.Reply
What mechanisms are used by a Servlet Container to maintain session information?
The mechanisms used by a Servlet Container to maintain session information :
b) URL rewriting
c) Hidden form fields
d) SSL (using HTTPS protocol) SessionsReply
What are the different ways for session tracking?
The concept of session tracking allows you to maintain the relation between the two successive request from the same client (browser). The browser sends the request to the server and server process the browser request generate the response and send back response to the browser. The server is not at all bothered about who is asking for the pages. The server (because of the use of HTTP as the underlying protocol) has no idea that these 2 successive requests have come from the same user. There is no connection between 2 successive requests on the Internet.
There are three ways of tracking sessions :
* Using Cookies.
* Using URL Rewriting.
* Using Hidden Form Fields.
What is difference between custom JSP tags and beans?
JSP has its own tag library that you can use in any nuber of pages. You can also create your own tags (Cusustom tags), define attributes and body of the tags and then group your tags into collections called tag library.
To use custom JSP tags, you need to define three separate components:
* Tag handler class.
* Tag library descriptor file.
* JSP file that uses the tag library.
When the first two components are done, you can use the tag by using taglib directive.
JavaBeans are Java utility classes you defined. Beans have a standard format for Java classes. Custom tags and beans accomplish the same goals � encapsulating complex behavior into simple and accessible forms.
Difference between custom JSP tags and beans :
* Custom tags require more work to set up than do beans.
* Custom tags can manipulate JSP content, beans cannot.
* Custom tags usually define relatively self-contained behavior, whereas beans are often defined in one servlet and used in a different servlet or JSP page.Reply
What is the difference between JSP and Servlets ?
JSP(Java Server Pages) and Servlets, both are server side executed program and used to generate dynamic web page. Servlets are pure java classes and compiled directly into the .class whereas JSP page is a combination of HTML and java code. First of all JSP is translated into java file and then compiled into servlet. Functionally both are same. Both use the Servlet API to communicate with the web server and the client. Both require a container on the server, such as Tomcat, which provides the environment and VM for the Java program. Servlets are best suited for request processing, handling the business logic while JSP is suitable for content generating (client view). It is easy to include HTML tag in JSP rather than servlet.Reply