Friday, June 18, 2004 04:54 AM
Q:Seesion Tracking, URL Re-Writing , URL Encoding ?
URL Encoding is a process of transforming user input to a CGI form so
it is fit for travel across the
network -- basically, stripping spaces and punctuation and replacing
with escape characters. URL Decoding
is the reverse process. To perform these operations, call
java.net.URLDecoder.decode() (the latter was (finally!) added to JDK
1.2, aka Java 2).
Example: changing "We're #1!" into "We%27re+%231%21"
URL Rewriting is a technique for saving state information on the user's
browser between page hits.
It's sort of like cookies, only the information gets stored inside the
URL, as an additional parameter.
The HttpSession API, which is part of the Servlet API, sometimes uses
URL Rewriting when cookies are unavailable.
Example: changing into
(or whatever the
actual syntax is)
(Unfortunately, the method in the Servlet API for doing URL rewriting
for session management is
There's also a feature of the Apache web server called URL Rewriting;
it is enabled by the mod_rewrite module.
It rewrites URLs on their way in to the server, allowing you to do
things like automatically add a trailing
slash to a directory name, or to map old file names to new file names.
This has nothing to do with servlets.
Q:What is Servlet Chaining ?
Q:what is the role of SingleThreadModel in servlet ?
Ans:It makes servlet thread safe, It restrict multiple threads to
access service() method.Only one thread
at a time can enter into the service method if servlet implements
Q:difference in JSP Include Directive & Action
Directive:Static include - compile time include,no mechanism to notify
change in included file.
Action:Dynamic Include - request time include, in case of any change in
included file, server recompiles
the included file.
Q:what is the difference between JSP and Servlet ?
Q:Servlet API - GenericServlet, HttpServlet, Servlet
Q:what are the different forward mechanism mechanism is available in
This method is used to re-direct, or "forward" the current
ServletRequest and ServletResponse
to another active component in the application.
Sends a temporary redirect response to the client using the specified
redirect location URL.
requestDispatcher.forward(ServletRequest request, ServletResponse
Forwards a request from a servlet to another resource (servlet, JSP
file, or HTML file) on the server.
Q:What is the difference between doGet() and doPost() ?
When you invoke a Servlet, the servlet engine passes the information on
to the Servlets service() method.
This method determines the type of request made (GET, POST, HEAD, ...)
and calls the function doTYPE,
like doGet, doPost. GET and POST just differ in the way form data is
sent from the browser to the server.
The method doGet handles data that has been attached to the url in the
url questionmark (name=value ampersand)+. Typically in a CGI you would
have to read the environment
variable QUERY_STRING to get this string of concatenated parameternames
and values. With the doPost
method, form data comes in through standard input stream, a cgi would
just need to open the input
stream and read until EOF to get the form data.
With Servlets, you don't need to read in the concatenated string of
parameternames and values.
The parsing is all done behind the scenes. You just need to call
getParameter regardless of how
the form data is actually sent in.
POST:The post method will cause the web browser to send the form values
in two steps.The browser first
contacts the server specified in the 'Action' attribute and once
contact is made, sends the form
values to the server in a separate transmission.The server is expected
to read the parameters from
a standard location.
GET:The get method will cause the web browser to contact the server and
send the form values
to the 'Action' URL (as command - line arguments) separating the values
by a question mark.
Limitation of parameter is 2kb , 1024 characters.
Q:What are implicit objects ?
Q:How do we handle Exception in JSP ?