





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An overview of java servlets and jsp (java server pages), two powerful and efficient technologies for building dynamic web applications. The author compares jsp and servlets, as well as jsp and asp, and discusses the advantages of java servlets, such as accessibility, avoiding html code duplication, and multi-lingual support. The document also covers open source tools like tomcat, eclipse, and mysql, and provides examples of jsp and servlet code.
Typology: Study notes
1 / 9
This page cannot be seen from the preview
Don't miss anything!






JSP vs. ASP
Embed logic in an HTML page and
parse it on the server-side
ASP (Active Server Pages)
JSP (Java Server Pages)
JSP vs. Servlets
2 ways to do the same thing
Regular Java programming
Access HTTP request/response info
JSP
Servlets
Open Source Tools
Server: Tomcat
Development Environment: Eclipse
Database: mySQL
Database Connectivity: JDBC
Build tool: Ant
Text Search: Lucene
Servers
Tomcat
Others ($$)
Tomcat Examples
JSP
Servlet
Real Example: ICDL
Online library of scanned children’s books
Technical needs
Per Page: Url Variables
Quick and dirty – like HTML forms
Client side:
Server side:
public void doGet (HttpServletRequest request, HttpServletResponse response) {
String id= request.getParameter ("id");
}
Per User: Session Variables
Remembering state about a user
Setting: public void doGet (HttpServletRequest request, HttpServletResponse response) { HttpSession ses= request.getSession (true); Profile profile=new Profile(“Hilary”) ses. setAttribute ("profile",profile); ses. setMaxInactiveInterval (1000); }
Getting: HttpSession ses= request.getSession (true); Profile profile= ses.getAttribute (“profile”)
Per Servlet: Context Variables
public class ContextListener implements ServletContextListener { public void contextInitialized ( ServletContextEvent event) { context = event. getServletContext (); String home=“www.icdlbooks.org”; context. setAttribute (“home”,var); } public void contextDestroyed (ServletContextEvent event) { context. removeAttribute (“home"); }
Per Servlet: Context Variables
Getting:
public class MyServlet extends HttpServlet{
public void doGet(…) { ServletConfig config= getServletConfig(); ServletContext context= config.getServletContext(); String home= (String) context.getAttribute (“home");
}