Dear All,
Please tell me the difference that lies between Servlet and a JSP and when to use each of these.Kindly clarify my doubt on this.
Thanks,
Ajay
-
Difference between Servlet and a JSP (1 messages)
- Posted by: Ajay Kumar
- Posted on: August 20 2003 14:19 EDT
Threaded Messages (1)
- Difference between Servlet and a JSP by Tom Cole on August 27 2003 13:00 EDT
-
Difference between Servlet and a JSP[ Go to top ]
- Posted by: Tom Cole
- Posted on: August 27 2003 13:00 EDT
- in response to Ajay Kumar
Generally speaking use Servlets to process data on the server and use JSPs to present data to the client.
For example, a jsp or html file can contain a <form> object. The action for the form would be a servlet. The servlet would manipulate the data, i.e. store it to a database, etc. The servlet could then gather any additional information, i.e. a database index for the new data, and then based upon success or failure would redirect the client to a jsp which would display the data that was posted along with the index.
JSPs and Servlets, in the long run, perform the same function. The Servlet container will compile your JSP into a servlet for you. For presentation though, JSPs are easier to write as you don't have to explicitly output information into a stream...it's handled for you.
I hope that helped.