Welcome Message

Hi, welcome to my website. This is a place where you can get all the questions, puzzles, algorithms asked in interviews and their solutions. Feel free to contact me if you have any queries / suggestions and please leave your valuable comments.. Thanks for visiting -Pragya.

October 25, 2009

Servlets and JSPs

GET requests can be bookmarked but POST can not be.
GET is idempotent(Its used for getting things from the server, its not supposed to change anything ) , POST is not

addHeader() and setHeader() methods of response : Both will add a header and value to response if the header is not already present. The difference between these two occurs when the header is already there.
setHeader() overwrites the existing value
addHeader() adds an additional value

We can not do a send redirect after writing to the response. If we try to do so, it will throw an llegal state exception

Difference b/w redirect and a request dispatch : redirect makes the client do the work and sendRedirect makes sth on the server do the work.

we can not use Servlet init param unless the servlet is initialised.

sendredirect is called on response and request dispatcher is called on request
response.sendRedirect() and request.getRequestDispatcher() and then dispatcher.forward()

Also, in case of request dispatcher, the URL is not changed, so the user does not get to know about that.

No comments: