Link to University of Stirling home page Link to Computing Science and Mathematics home page
Go back Go back

Servlet and JSP demonstrations

  • A Very Dull Page in PHP. This is lifted from CSC9W6. (Source code)
  • A Very Dull Page as a Servlet (Source code)
  • The Not Quite So Dull Page (with a global variable to demonstrate the servlet lifecycle) (Source code)
  • Page containing a simple form, with one input field, that invokes a PHP script. The script displays the value of the input field in its result. (PHP source code)
  • Page containing a form, with two input fields, that invokes a PHP script. The script displays the values of the two form input fields. (PHP source code)
  • The same form, but this time invoking a servlet that already "knows" the names of the fields (Form source code Servlet source code)
  • The same form, but this time invoking a servlet that uses request.getParameterNames() and displays the values of all the request parameters. The servlet also shows any cookies that were returned by the client (Form source code, Servlet source code, Furniture source code)
  • Almost the same form, but transmitting the data using "POST". Can the servlet cope? (Form source code)
  • A servlet that uses JDBC to connect to Oracle using a globally available dummy username and password, and ask about pantomimes in Stirling. (Source code)
  • A similar servlet that uses JDBC to connect to MySQL using a globally available dummy username and password, and ask about pantomimes in Stirling. (Source code)
  • A servlet like the previous one that uses JDBC to connect to Oracle and ask about pantomimes in Stirling, but this time using the table owner's username and password fetched from a secure file. (Source code)
  • A similar servlet that uses JDBC to connect to MySQL and ask about pantomimes in Stirling, but this time using the table owner's username and password fetched from a secure file. (Source code)
  • A servlet that demonstrates session maintenance. The session-length has been made deliberately very short so that you can see when it has timed-out. (Source code)
  • Almost the same servlet, but this time with an embedded link to a twin page so that you can see several pages accessing the same session. (Ping source code, Pong source code)
    Also contains a link to ...
  • A servlet that kills the current session. (Source code)
  • Two versions of the VeryDullPage including the current date and time. One version is a servlet and the other is a JSP page (Servlet source code, JSP source code)
  • A JSP page that instantiates a page scope Java bean PersonBean and then displays its properties. (JSP source)
  • A JSP page that instantiates a page scope Java bean PersonBean, displays its properties, then updates the age and address from submitted form data (in the URL in this example). (JSP source)
  • A JSP page that creates a request scope Java bean PersonBean, displays its properties. This is a servlet that sets an appropriate bean into the request data and forwards the request to the same JSP page - this time the JSP does not create a new bean but displays the one that it received. (JSP source, servlet source)
  • A servlet that fetches all the request headers that it receives from the client browser and reports them back as a web page. (Source code)
  • A servlet that reports the results of calling getServletName and request.getServletPath to illustrate the effect of servlet and servlet-mapping elements in web.xml. (Source code)

Go back Go back

If you have any difficulties accessing this page, or you have any queries/suggestions arising from this page, please email:

Link to Computing Science and Mathematics home page
© University of Stirling 2017           Last updated: Wednesday, 23-Nov-2016 17:31:44 GMT
The University of Stirling is a charity registered in Scotland, number SCO11159