The Need for JSP
With servlets, it is easy to
Read form data
Read HTTP request headers
Set HTTP status codes and response headers
Use cookies and session tracking
Share data among servlets
Remember data between requests
Get fun, high paying jobs
But, it sure is a pain to
Use those println statements to generate HTML
Maintain that HTML
3
JSP
www.corewebprogramming.com
The JSP Framework
Idea:
Use regular HTML for most of page
Mark servlet code with special tags
Entire JSP page gets translated into a servlet (once), and
servlet is what actually gets invoked (for each request)
Example:
JSP
Thanks for ordering
<%= request.getParameter("title") %>
URL
http://host/OrderConfirmation.jsp?title=Core+Web+Programming
Result
Thanks for ordering Core Web Programming
4
JSP
www.corewebprogramming.com
2