Exercises, examples and other material relating to training module J906. This topic is presented on public courses
Learning to Program in Java,
Java Bootcamp,
Java Programming for the Web
If you're writing a substantive web application, you're likely to have a number of visitors to your site at the same time, with each of them calling up a series of screens. In this module, we examine parameter handling, session control, and the persistence of servlets from one call to the next.
Related technical and longer articles
Sessions in Servlets
Articles and tips on this subject | updated |
4432 | Java web application for teaching - now with sessions and clustering / load balancing demonstrations I regret naming "latmjdemo" with that name when I prut together a web application for the Java version of our web deployemnt course. The nameing isn't random:
• L - Linux, the operating system
• A - Apache - the Apache httpd web server that's commonly used to front web sites
• T - Tomcat ... | 2015-02-19 |
4431 | A Java servlet that is also a stand alone program. And a server that is also a web client. I've been teaching the fundamentals of Java (a private 4 day course) to a number of groups over the past few weeks - each time tailoring the course towards the projects that the delegates (within a large organisation) will be using it for, and also tailoring to suite the background of the delegates. ... | 2015-02-19 |
3293 | Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) Have you ever tried to sort out a complex situation with a supplier - perhaps something's gone wrong with your electic and gas bills (as happened with us a couple of months ago, when our gas payment got credited to our electic account with the same company). You get on the phone, and the initial person ... | 2011-05-18 (longer) |
3044 | Changing a Servlet - more that just editing and compiling If you're going to modify a servlet, you'll need to edit and recompile the classes that you're changing - and chances are that will include the main application class. Which means you need to have access to the source. Not a problem if you're a developer of the product, but could be an issue if it's ... | 2010-11-12 |
2717 | The Multiple Inheritance Conundrum, interfaces and mixins Should an OO programming language support "multiple inheritance"? Let's define multiple inheritance first - starting from simple (single?) inheritance.
(Single) Inheritance.
I don't want to have to define each type of thing ("class of object") from scratch, so I'll define once class as being based ... | 2010-04-13 |
2652 | Reading and writing cookies in Java Servlets and JSPs Do you want to check (and perhaps set) cookies within a Java Servlet? I was looking around for good, straightforward examples today but found that most of the published code is only snippets rather than complete examples, or is over-complex for what should be a simple demo.
First - do you really want ... | 2010-02-26 |
2183 | Servlet life cycle, and Java Servlet variable scope If you write a 'traditional' program and run it ... then it is cleared from memory when you finish running it. It does its job then exits. And so it is with a java program that you run from the command line under the java command.
But if you're running a web server, where lots of users all call up ... | 2009-05-16 |
1909 | javax.servlet cannot be resolved - how to solve Two common problems in compiling Servlets for use within a Tomcat container ...
PROBLEM: My Java Compile of a Servlet says "javax.servlet cannot be resolved"
For example:
[trainee@easterton sources]$ javac Smallest.java
----------
1. ERROR in Smallest.java
(at line 2)
import javax.servlet.*;
^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
2. ERROR in Smallest.java
(at line 3)
import javax.servlet.http.*;
^^^^^^^^^^^^^
The import javax.servlet cannot be resolved
----------
3. ERROR in Smallest.java
(at line 5)
public class Smallest extends HttpServlet {
^^^^^^^^^^^
HttpServlet cannot be resolved to a type
----------
4. ERROR in Smallest.java
(at line 9)
public void doGet(HttpServletRequest request,
^^^^^^^^^^^^^^^^^^
HttpServletRequest cannot be resolved to a type
----------
5. ERROR in Smallest.java
(at line 10)
HttpServletResponse response)
^^^^^^^^^^^^^^^^^^^
HttpServletResponse cannot be resolved to a type
----------
6. ERROR in Smallest.java
(at line 11)
throws IOException, ServletException
^^^^^^^^^^^^^^^^
ServletException cannot be resolved to a type
----------
6 problems (6 errors)[trainee@easterton sources]$
SOLUTION: ... | 2008-11-26 |
1550 | Java (JSP and Servlet examples) live on our server On our Java Programming for the Web and Deploying Apache httpd and Tomcat courses, we provide a ready-written demonstration that includes simple web pages, a basic JSP, JSPs with tag libraries, and a couple of Servlets - with some calling up data from a MySQL database.
I have uploaded the examples so ... | 2008-02-27 |
1495 | Single login and single threaded models - Java and PHP On Apache Tomcat courses, I find myself explaining "single login" models and on some Java courses I explain single threaded models. In both cases, there are times that newcomers to the technologies ask "does it matter".
Answer - for a small and quiet application suite, probably not - but as the ... | 2008-01-08 |
479 | New servlet from old Check list - how to modify a Servlet and install it under a new name on your Tomcat server. This scheme assumes that you're working at a machine that has Java installed, but doesn't have its own copy of Tomcat and all the extras (why would it - it's your development machine and not the server!)
1. ... | 2006-06-05 |
Examples from our training material
Background information
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
[here].
Topics covered in this module
Introduction.
What is a Servlet?.
How do Servlets fit into the scheme of things?.
What alternatives are there to servlets?.
Servlet Engines.
Java Class Structure.
Data Interface.
A first servlet.
Reading from a form.
At a higher level.
Get v Post.
The life of a servlet.
Initialisation.
Destruction.
Maintaining State.
Session Objects.
Rewriting URLs.
Hidden fields.
Programming techniques.
Webifying output.
Keeping code and pages separate.
State Diagrams.
Other facilities of servlets.
Multiuser Servlets.
Servlet Descriptions.
Cookies.
Sessions in Servlets.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Java,
Ruby,
Lua,
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre.