examples.servlets
Class HelloWorld2
java.lang.Object
|
+--javax.servlet.GenericServlet
|
+--javax.servlet.http.HttpServlet
|
+--examples.servlets.HelloWorld2
- All Implemented Interfaces:
- java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
- public class HelloWorld2
- extends javax.servlet.http.HttpServlet
The HelloWorld2 servlet uses initialization parameters to display
two strings in the output ("Welcome WebLogic Developer!"). If the initialization parameters are not
defined, default strings defined in this example are
used. Initialization parameters are defined in the web.xml file that defines a Web
Application, in this case the examplesWebApp. The web.xml file is located in your WebLogic Server
distribution at config/examples/applications/examplesWebApp/WEB-INF/web.xml.
The HelloWorld3 example contains exactly the same
Java code as the HelloWorld2
example, but the initialization parameters are not defined in the
web.xml file.
Build the Example
- Open a new command shell.
- Set up this development shell as described in Setting up Your Environment for
Building and Running the Examples.
- Compile the servlet
using the following command line:
$ javac -d %EX_WEBAPP_CLASSES% HelloWorld2.java
- Start WebLogic Server with the examples configuration.
Configure the Server
- Make sure that the examplesWebApp is deployed on your server.
Run the Example
- Use a web browser to load the following URL:
http://localhost:7001/examplesWebApp/HelloWorld2
There's more
For more information on servlets see Programming WebLogic HTTP Servlets.
- Author:
- Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.
Method Summary |
void |
init(javax.servlet.ServletConfig config)
|
void |
service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
A very simple implementation of the service method, in
which we output the contents of a static html page |
Methods inherited from class javax.servlet.http.HttpServlet |
, doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
defaultGreeting
java.lang.String defaultGreeting
defaultName
java.lang.String defaultName
HelloWorld2
public HelloWorld2()
init
public void init(javax.servlet.ServletConfig config)
throws javax.servlet.ServletException
- Overrides:
init
in class javax.servlet.GenericServlet
service
public void service(javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
throws java.io.IOException
- A very simple implementation of the service method, in
which we output the contents of a static html page
- Overrides:
service
in class javax.servlet.http.HttpServlet
Copyright © 2000 BEA Systems, Inc. All Rights Reserved.