java4all@1986 java. Powered by Blogger.

>> Wednesday, June 15, 2011

Q).Is Servlet is Thread Safe ?How to make Servlet as Thread Safe?
A.)
Servlet is not thread safe.it allows to access more than one
thread at a time.IF we want to make servlet as a thread safe
then make service method is synchronized or implement
SingleThreadModel interface.There is no methods in this
interface.
 
Q).What is difference between Forward() and sendRedirect()?
A.) The RequestDispatcher forward and include methods are 
internal to a servlet container and does not affect the 
public url of the webresource.

forward() are excute on the server side.

when a forward() is invoked,the request is sent to another 
resource on the server without the client being inform that 
a different resource is going to process the request.This 
occurs completely with in the webcontainer.

sendRedirect() excutes on the client side.

When a sendRedirect()is invoked,it causes the webcontainer 
return to the browser,indicating that a new url should be 
requested because the browser issues a completely new 
request,any object that are stored as request attributes 
before the redirect occurs will be lost.
This extra round trip,a redirect is slower than forward.
 
Q).What is Difference Between webserver and application server?  
A).1) Webserver serves pages for viewing 
in web browser, application server provides exposes businness logic for 
client applications through various protocols

(2) Webserver exclusively handles http requests.application server 
serves bussiness logic to application programs through any number of 
protocols.

(3) Webserver delegation model is fairly simple,when the request comes 
into the webserver,it simply passes the request to the program best able
 to handle it(Server side program). It may not support transactions and 
database connection pooling.

(4) Application server is more capable of dynamic behaviour than 
webserver. We can also configure application server to work as a 
webserver.Simply applic! ation server is a superset of webserver.

Q.)Can it possible to validate form fields before execution of servlet service m
    method and how if yes?
A.)We can do it, There are two validation is available

1. Form validation
2. Server side validation

1. Form Validation - This validation is perform client side,
java script used to achieve these form validation

2. Server side Validation - This type we can use predefined
server side validation method used to achieve these validate.

Note:- In perform wise we compare Form validation is better
than server side validation. it's easy to progress.
 
Q.) What is the need of session Tracking in HttpServlet? 
A).As per http protocol no user information is  pertained. 
every request is considered as a new request and there will 
not be any session maintained between requests. so to 
maintain users information we have to use session 
tracking
 
Q).What happen if we wont use destroy()?  
A). 
Think, if there is 100's of objects are utilizing the
resource(i.e Connection object). That means allocation of
those objects are stored in the internal memory of the JVM
right... If similar requests are utilizing the Connection
object.... at one time the JVM utilization memory is full...
this will degrade the application. For this reason we call
explicitly destroy()...... if not the Garbage Collector will
taken care to reclaim the memory.... by we don's say when it
will be reclaim the memory and free the JVM memory......

0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP