java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.voytechs.html.application.ToolServlet
com.voytechs.example.helloworld.HelloWorldServlet
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class HelloWorldServlet
- extends com.voytechs.html.application.ToolServlet
This is a sample application which simply displays HelloWorld message back to the client
browser.
Here is how we write this application.
- subclass the ToolServlet class and define its abstract method createSessionPanel.
- In the method createSessionPanel() we create a new panel, add a Text("Hello World!!!") object and return it.
To install this application in your servlet environment, for tomcat we do the following. We have to
define the new servlet in web.xml file and copy the files to the appropriate tomcat directory.
We add to WEB-INF/web.xml file:
HelloWorld
com.voytechs.example.helloworld.HelloWorldServlet
5
| Fields inherited from class com.voytechs.html.application.ToolServlet |
|
| Fields inherited from class javax.servlet.http.HttpServlet |
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
HelloWorldServlet
public HelloWorldServlet()
- Constructor for our HelloWorld application. We simply need to do this step to define a uniq
name for our application. This isn't really needed by our simple applicaton, but some advanced
functionality utilizes these application names to allow servlets to interface with each other
, ie. ToolServlet.getToolServlets().
So to be a sport, we need to provide the application name.
createSessionPanel
public com.voytechs.html.component.Panel createSessionPanel()
throws com.voytechs.html.event.EventException
- This method is called for every new user session the servlet creates. That is, there is only
1 HelloWorldServlet object instance, but there can be many Panel object instances.