Extend a Java Class Inside a JSP Page?

Hello all. I'm not sure if I am thinking about this right. But what I have is a BaseClass that all of my other classes Extend. I'm inside a JSP page and want to use all of the functionality of that BaseClass. Is there anyway I can EXTEND A CLASS INSIDE A JSP PAGE or am I smoking crack?

Its an attribute of the page directive
"extends="package.class"
The fully qualified name of the superclass of the Java class this JSP page will be compiled to. Use this attribute cautiously, as it can limit the JSP container's ability to provide a specialized superclass that improves the quality of the compiled class. "
http://java.sun.com/products/jsp/tags/12/syntaxref1210.html#15653

Similar Messages

  • How can i call java class file in jsp page

    Hai,
    i wants to call .class file in jsp page.
    my class file is in C:\jsdk\bin.
    Thanks

    I'm not entirely sure what you mean by "calling a class file", but I'm going to assume that you want to do something like the following in your page:
    <%
    MyClass myClass = new MyClass();
    myClass.someMethod();
    %>etc
    If that's the case, then all you have to do is make sure that the class is in the servlet engine's classpath. You'll probably also need to include an appropriate import statement at the top of the page.
    Hope that helps.

  • Loading Java Class File in JSP page

    I'm trying to load a java class file from a jsp page.
    (e.g. MyFile.java <-- Source "MyFile.class<--Class file of MyFile.java")
    jsp page
    <%@ include file = "MyFile.class" %>
    <HTML> // HTML Tags are here
    MyFile.java
    A normal java source file that has "public static void main" in it.
    My jsp page can display it's contents, 'except' for showing e.g. "1235%%215648%%public%%$$@##" through out the page...
    My guess is that it can't display my java class file..
    Can anyone please help me solve this problem of mine ?
    Thanks in advance : )
    Yours Sincerely,
    RainbowEnergies

    This is my JSP file.
    <HTML>
    <HEAD>
    <TITLE>Activity Games</TITLE>
    </HEAD>
    <%
    String name = "";
    String id = "";
    name = session.getAttribute("name").toString();
    session.setAttribute("name",name);
    id = session.getAttribute("id").toString();
    session.setAttribute("id",id);
    %>
    <BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
    <H3><%=name%>, you have enter Activity Games</H3>
    <%@ page import="Games.Lufia.*" %>
    <%Lufia lufia = new Lufia();%>
    </BODY>
    </HTML>
    After I execute...
    An error occurred at line: 18 in the jsp file: /jsp/ActivityGames.jsp
    error: File C:\Program Files\Apache Tomcat 4.0\webapps\website\WEB-INF\classes\Games\Lufia\Lufia.class does not contain type Games.Lufia.Lufia as expected, but type Lufia. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
    Generated servlet error:
    C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\website\jsp\ActivityGames$jsp.java:85: Class Games.Lufia.Lufia not found.
    Lufia lufia = new Lufia();
    But if I comment this out....
    This is my JSP file.
    <HTML>
    <HEAD>
    <TITLE>Activity Games</TITLE>
    </HEAD>
    <%
    String name = "";
    String id = "";
    name = session.getAttribute("name").toString();
    session.setAttribute("name",name);
    id = session.getAttribute("id").toString();
    session.setAttribute("id",id);
    %>
    <BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
    <H3><%=name%>, you have enter Activity Games</H3>
    <%@ page import="Games.Lufia.*" %>
    <%//Lufia lufia = new Lufia();%> <--- comment this out.... (HERE)
    </BODY>
    </HTML>
    The page shows but did not run my java class file..
    Thanks again for trying to help me solve this problem of mine. : - )
    Regards,
    RainbowEnergies

  • Recompilation of java class invalidates taglib jsp page?

    Hi everyone,
              I have a JSP page which calls a custom tag library. On freshly compiling
              everything and
              calling the JSP page from a browser for the first time the output is as
              expected.
              However when ever I recompile one of the classes that get called anywhere in
              the tag
              library call the tag no longer works (internal error from the server).
              To get it to work I have to change the jsp page so that it recompiles.
              Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
              Any ideas?
              MTIA
              Craig
              

    p.s
              The following errors are in the log file.
              Is this another class casting problem?
              Does any one have any explanations?
              Ta
              Craig
              <ServletContext-General> Servlet failed with Exception
              javax.servlet.ServletException: runtime failure in custom tag 'MyTag'
              at jsp_servlet._taglib._jspService(_taglib.java:89)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              , Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java, Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
              <ServletContext-General> root cause of ServletException
              java.lang.ClassCastException: com.bt.db.MyTag
              at jsp_servlet._taglib._jspService(_taglib.java:77)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              , Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java, Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
              "crg" <[email protected]> wrote in message
              news:[email protected]...
              > Hi everyone,
              >
              > I have a JSP page which calls a custom tag library. On freshly compiling
              > everything and
              > calling the JSP page from a browser for the first time the output is as
              > expected.
              > However when ever I recompile one of the classes that get called anywhere
              in
              > the tag
              > library call the tag no longer works (internal error from the server).
              > To get it to work I have to change the jsp page so that it recompiles.
              >
              > Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
              >
              > Any ideas?
              > MTIA
              >
              > Craig
              >
              >
              >
              >
              

  • How to Generate a Java file for a JSP Page

    Hi ,
    I am using weblogic11 .
    I am working on a JSP page which nearly consists of 4000 lines of code.
    I need to debug the file , but weblogic server is not generating the java file for the JSP pages .
    Please let me know how can i genertae Java file for the jsp pages ??

    JSPs are compiled into servlets automatically and those classes are stored in WEB-INF/classes folder. Servlet engine handles servlets.

  • How to use self-defined class in a jsp page

    Hello:
    I defined a class for displaying purpose, which is in the different folder(WEB-INF/classes) from my JSP page.
    In my JSP page, I want to create an instance of my class and display something, while I get the following error: "
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 12 in the jsp file: /htmls/templateIntro.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /home/jiao/jsp_webserver/tomcat/work/Standalone/localhost/syllabus/htmls/templateIntro_jsp.java:72: cannot resolve symbol
    symbol : class Display
    location: class org.apache.jsp.templateIntro_jsp
    Display display=new Display(out);"
    How can I solve this problem? Should I redefine my classpath or there are some other actions I should take.
    T.I.A.
    Oriental Spirit

    Here is what I have done:
    1) in Display.java, add one line "package tools;" on the top, and compile it to
    create Display.class.
    2) create a new folder at
    /home/jiao/jsp_webserver/tomcat/webapps/syllabus/WEB-INF/classes
    named tools and then put the Display.class into the newly created folder.
    3) in my jsp page, add " import="tools.*"
    But it still doesn't work.
    Any ideas? T.I.A.

  • Import java classes in a JSP

    hallo
    I have craeted aPackage "TestPackage" as subdirectory in the order
    tomcat\webapps\ROOT\WEB-INF\classes\TestPackage
    in this package ther ist the class Test
    I try to imort this class in the jsp
    <%@ page language="java" import="TestPackage.*"%>
    <jsp:useBean id="app" scope="page" class="Test"/>
    <%
    for(int i=0; i< 10; i++){
    %>
    <h1><%= app.getName()%></h1>
    <%
    %>
    error:
    [javac] C:\tomcat4\work\Standalone\localhost\_\test_jsp.java:43: cannot resolve symbol
    [javac] symbol : class Test
    [javac] location: class org.apache.jsp.test_jsp
    [javac] Test app = null;
    who ist the Problem ???
    thanks

    Hi Orient,
    Actually <jsp:useBean /> takes fully qualified class name.
    so your code for <jsp:useBean /> should be like this
       <jsp:useBean id="app" scope="page" class="TestPackage.Test"/>
      For more details please refer http://java.sun.com/products/jsp/tags/11/syntaxref1115.html
    Regards
    Goodieguy

  • Unable to import a java class in a jsp file

    Hi,
    I am trying to import a java class in my jsp.
    ------------------jsp---------------
    <jsp:useBean id="form" class="com.company.portlets.searchApps.object.SearchOBJ" scope="request" />
    <jsp:setProperty name="form" property="*" />
    <input type="TEXT" name="projectID" value='<%= form.getProjectID() %>'>
    When I run the above JSP, it says that class 'com.company.portlets.searchApps.object.SearchOBJ' cannot be found.
    Why?
    My project structure looks like this:
    Project
    +Application Sources
    ++com.company.portlets.searchApps.object
    +++SearchOBJ.java
    +Web Content
    ++htdocs
    +++searchappsportlet
    ++++SearchAppsPortletShowPage.jsp
    ++WEB-INF
    +++index.jsp
    +Resources
    ++SearchApps.deploy
    Please advice...thanks!

    The way that JDeveloper organized the files was like this:
    C:\jdev1012\jdev\mywork\WksSearchApps\Project\classes\com\company\portlets\searchAPPS\object\SearchOBJ.class
    I am assuming that JDeveloper puts the file where they are suppose to be...if not, how do I change that?
    thanks,
    hussain

  • I used tag to show PDF file inside my JSP page, It is working properly in IE but nothing shows in Mozilla. What should I do?

    I've used to display a PDF file inside my JSP page. It is working fine in IE. However, many of users of this application are using Mozilla and the platform is Ubuntu so it is vital that the file is shown in Mozilla as well. How can I solve this problem.
    == This happened ==
    Every time Firefox opened
    == I run my jsp page

    Such conditional code will only work in IE and not in other browsers like Firefox.
    You can ask questions and advice about web development at the mozillaZine Web Development/Standards Evangelism forum.<br />
    A good place to ask questions and advice about web development is at the mozillaZine Web Development/Standards Evangelism forum.<br />
    The helpers at that forum are more knowledgeable about web development issues.<br />
    You need to register at the mozillaZine forum site in order to post at that forum.<br />
    See http://forums.mozillazine.org/viewforum.php?f=25

  • How i can make  my own connection in java source of a jsp page

    How i can make my own connection in java source of a jsp page (How to get connection from JNDI datasource address) ?
    imagine that i have a rowset in a web page , now i want to do some operation using
    plain JDBC , so i will need a connection object.
    I tried to get one of my rowsets connection but it return null ?
    what is best way to retrive a connection from JNDI datasource that we define for our project?
    for example if i have
    myRowSet.setDataSourceName("java:comp/env/jdbc/be");
    in web page constructor
    now i want a pure connection from the same datasource ? JNDI
    Thank you

    It is not hard to get your own connection from datasource.
    in your case you need to do like the the following code.
    i provide sample to show you how to catch the exception and create an statement .
    Connection con =null;
    try{
    InitialContext ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/be");
    con = ds.getConnection();
    java.sql.Statement st =con.createStatement();
    }catch(SQLException sqlex){
    sqlex.printStackTrace();
    sqlex.getNextException().printStackTrace();
    catch(NamingException nex){
    nex.printStackTrace();
    hth
    Masoud kalali

  • Using java class files in JSP

    hi everyone,
    i am trying to import a java file in a JSP page..
    how do i do this???

    hi,
    <%@page import="yourpackagename.*" %>
    or
    <%@page import="yourpackagename.classname" %>

  • Access Java class in my JSP/JSF page and conditionally open a new browser

    When the user clicks on a button in my JSP page, I'd like to launch a new browser and display certain things in that browser window while leaving the original browser window open.
    My thought was to invoke a javascript method in 'onLoad' which would determine if the new window needs to be launched.
    This is kinda what my page looks like:
    <jsp:root version="1.2" ................>
        <jsp:directive.page import="java.util.*, com.test.Configuration" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <f:view>
         <ui:body binding="#{Page1.body1}" id="body1" onLoad="launchWindow();">     
         </ui:body>
       </f:view>
       <script type="text/javascript">
            function launchWindow(){
             if (Configuration.openWindow()) {
              window.open("hello.jsp", "newWindow", 'toolbar,width=400,height=400');            
        </script>     
    </jsp:root>My problem is that the call to "Configuration.openWindow()" does not resolve correctly. If I remove that call and simply make a call to "window.open()" all works. But once I put the condition in, nothing happens. I do not see an exception in my browser window but a new browser window does not open.
    Is my syntax correct. Can I make a call to the static method 'openWindow()' in my class 'Configuration.java'.
    thanks,
    tsc

    I have made some changes so that I do not directly access the 'Configuration' class in my javascript.
    I have a hidden field on my form and when the user clicks the button, in my back bean, I set a value for the hidden field. In the javascript function 'launchWindow()' I check if a value has been set for the hidden field and if yes, I open a new window.
    <ui:body binding="#{Page1.body1}" id="body1" onLoad="launchWindow(document.forms[0]);">
    <h:inputText id="hiddenField" value="#{formBean.hiddenValue}" />
    <script type="text/javascript">
            function launchWindow(form){
                alert("in lw");
                var test = form["form1:hiddenField"].value;
                alert("got test");
                if (test !=  "")
                    window.open("hello.jsp", "newWindow", 'toolbar,width=400,height=400');            
                alert ("done test");
    </script>When my page is first loaded, the launchWindow() is called and all the alerts popup as expected.
    When I click on the button (the back bean sets the value on the hidden field), my page is reloaded but this time its blank.
    Any ideas as to why this maybe the case?
    thanks,
    tsc

  • How to import a java class in a JSP

    Hi All,
    I have a java class file called myTest.class (i made after compilation of myTest.java). I have a JSP page that uses this java class file.
    These 2 files are in same folder called c:/test
    and iam importing this java class file into my jsp file and that too at the start of this jsp file:
    <%@page import="myTest" %>
    BUt iam getting an error ..............when iam running this JSP page:
    /opt/bea81sp2/user_projects/domains/wliDomain/./Managed2/.wlnotdelete/extract/Managed2_myTest_myTest/jsp_servlet/__test.java:20: '.' expected
    probably occurred due to an error in /test.jsp line 5:
    <%@page import="myTest" %>
    Please advise how to solve this problem
    -sangita

    Don't bother with the import
    when iam not importing this class file into my JSP, then on my JSP, the class file is not found.
    Here is my code: and these 2 class file are in c:/test
    import org.apache.tools.ant.taskdefs.Ant;
    import org.apache.tools.ant.taskdefs.Property;
    import org.apache.tools.ant.types.*;
    import org.apache.tools.ant.*;
    import org.apache.tools.ant.taskdefs.ExecTask;
    import org.apache.tools.ant.types.Commandline;
    import java.io.File;
    * Creates an Ant project to run an Ant build
    * @author myself
    * @version 1.0
    public class RunTest extends Ant {
        String applicationName;
        String buttonClicked;
        String boxName;
        String targetName;
        public void applicationName(String applicationName){
         this.applicationName = applicationName;
        public void boxName(String boxName){
         this.boxName = boxName;
        public void buttonClicked(String buttonClicked){
         this.buttonClicked = buttonClicked;
      public RunTest() {
    public void goTest() {
         if(this.buttonClicked.equalsIgnoreCase("deploy") && this.applicationName.equalsIgnoreCase("scsmail") && this.boxName.equalsIgnoreCase("testnet")){
           this.targetName = "deploy-scsmail-testnet";
         if(this.buttonClicked.equalsIgnoreCase("undeploy") && this.applicationName.equalsIgnoreCase("scsmail") && this.boxName.equalsIgnoreCase("testnet")){
           this.targetName = "undeploy-scsmail-testnet";
        Project project = new Project();
        project.init();
        System.out.println("printing 1 ....");
        ExecTask exec = new ExecTask();
        exec.setProject(project);
        exec.setExecutable("/opt/bea/weblogic81/server/bin/ant.bat");
         exec.setDir(new java.io.File("/export/home/beamon/bin"));
         Commandline.Argument arg = exec.createArg();
         // arg.setLine("-f scsmail.xml test -listener org.apache.tools.ant.XmlLogger -logfile D:/antProject/src/log.xml");
         arg.setLine("-f build.xml "+ targetName + " -listener org.apache.tools.ant.XmlLogger -logfile /export/home/beamon/bin/log.xml");
         System.out.println("printing 2....");
        //exec.setOutput(new File("D:/antProject/logs/prob.txt"));
        exec.execute();
        System.out.println("printing 3....");
    -----------------------the JSP page is called as test.jsp
    <%@page contentType="text/html" %>
    <%@page import="java.io.*" %>
    <%@page import="java.util.*" %>
    <%@page import="java.net.*" %>
    <%@page import="RunTest" %>
    <HTML>
    <TITLE>TESTING ANT GUI</TITLE>
    <HEAD>
    <META HTTP-EQUIV="Refresh" CONTENT="3000" >
    <meta http-equiv="Cache-Control" content="no-cache">
    </HEAD>
    <BODY BGCOLOR="silver" TEXT="333333">
    <table border=0>
    <tr align="left"><td align="left"><FONT SIZE="-1"><B>  Test Page <FONT SIZE="-1"><B></td></tr>
    </table>
    <hr></center>
    <form action="./test.jsp" method="POST" name="testForm">
    <table>
    <tr>
    <td>
    <select name="appName" size=1>
    <option value="">Select Application Name
    <option value="scsmail">scsMail
    <option value="clientmanager">ClientManager
    </select>
    </td>
    <td>
    <select name="boxName" size=1>
    <option value="">Select Box Name
    <option value="testnet">TestNet
    <option value="production">Production
    </select>
    </td>
    </table>
    <table>
    <input type="submit" name="deploy" value="deploy">
    <input type="submit" name="undeploy" value="undeploy">
    </table>
    <%
       RunTest rt = new RunTest();
       rt.applicationName(request.getParameter("appName"));
        String deployButton = "";
        deployButton=request.getParameter("deploy");
        String undeployButton = "";
        undeployButton=request.getParameter("undeploy");
        if(!deployButton.equalsIgnoreCase("")){
            rt.buttonClicked(request.getParameter("deployButton"));
        if(!undeployButton.equalsIgnoreCase("")){
            rt.buttonClicked(request.getParameter("undeployButton"));
       rt.boxName(request.getParameter("boxName"));
        rt.goTest();
    %>
    </form>
    </table>
    </BODY>
    </HTML>

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • Tomcat 6 – Calling a  Java Servlet from a JSP Page

    Below is a very simple JSP Page that calls a Java Servlet. The question is given Tomcat security constraints, is it possible to call a servlet from a JSP and get the correct output without getting an error message? If so, how would you code the web.xml file?
    c:\apache-tomcat-6.0.18
    Under conf
    catalina
    localhost
    HelloWorldExample.xml is directly under localhost
    The application would have this directory structure:
    webapps
    HelloWorldExample
    hello.jsp is directly under HelloWorldExample
    Under HelloWorldExample
    src
    WEB-INF
    classes
    Under classes
    jservlets
    HelloWorld.java is in src folder
    HelloWorld.class is in jservlets folder
    HelloWorldExample.xml
    <Context path="/HelloWorldExample" docBase="HelloWorldExample" debug="0"
          reloadable="true" crossContext="true">    
    </Context>**************************
    hello.jsp
    <HTML>
    <HEAD>
    <TITLE>Hello</TITLE>
    </HEAD>
    <BODY>
    <FONT SIZE="4">
    <P>
    Please enter your name:
    <FORM 
       METHOD="Post"
       ACTION="servlet/jservlets.HelloWorld">
    <TABLE BORDER="3" CELLPADDING="1" WIDTH="100%" ALIGN="CENTER">
    <TR>
        <TD><B>Name:</B></TD>
        <TD><INPUT TYPE="text" NAME="Name" VALUE="" SIZE="65"> </TD>      
    </TR>
    </TABLE>
    <P>
    <INPUT TYPE="SUBMIT" VALUE="Submit">
    </FORM>
    </FONT>
    </BODY>
    </HTML>******************
    HelloWorld.java
    package jservlets;
    import java.io.*;
    import java.util.Date;
    import java.util.*;
    import java.text.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorld extends HttpServlet
       PrintWriter out;
       PrintWriter err; 
       String strName;
    public void displayMessage(HttpServletRequest request, HttpServletResponse response)
          throws Exception
             try
                if (!strName.equals("") && strName != null)
                   out.println("Hello " + strName + "" + "<P>");
                    out.println("Hello World" + "<P>");
                else
                    out.println("Hello World" + "<P>");
            catch (Exception e)
                out.println("Exception: Could not display message." + "<P>");
                err.println (e.getMessage () ) ;
                out.println("<P>");
    public void doPost(HttpServletRequest request, HttpServletResponse response)
               throws ServletException, IOException
          try
               response.setContentType("text/html"); 
               out = response.getWriter();
               err = response.getWriter();
               strName = request.getParameter("Name").trim();
               out.println("<html><head><title>");        
              out.println("</title></head><body>");
               out.println("<FORM");
               out.println("METHOD=POST");
               out.println("ACTION=http://localhost:8080/HelloWorldExample/hello.jsp>");
             out.println("<TABLE ALIGN='RIGHT'>");
             out.println("<TR>");
             out.println("<TD>");          
               out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Hello World Page\";>");
               out.println("</INPUT>");
              out.println("</TD>");
             out.println("</TR>");
             out.println("</TABLE>");
             out.println("</FORM>");
             out.println("<BR CLEAR='all'>");
               out.println("<P>");        
               displayMessage(request, response);
               out.close();
             out.println("</body></html>");               
           catch(Throwable e)
              e.printStackTrace();
          public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException
             doPost(request, response);
    web.xml
    <servlet>
          <servlet-name>HelloWorld</servlet-name>
          <servlet-class>jservlets.HelloWorld</servlet-class>
    </servlet>  
    <servlet-mapping>
            <servlet-name>HelloWorld</servlet-name>
            <url-pattern>/servlet/HelloWorld</url-pattern>
    </servlet-mapping>      ******************************
    HelloWorld.java can be compiled by using javac.
    Once compiled, HelloWorld.class would be moved to the jservlets folder.
    FYI, coding the above url-pattern results in:
    HTTP Status 404
    The requested resource (/HelloWorldExample/servlet/jservlets.HelloWorld) is not available
    The following url-pattern in the web.xml file permits the servlet to be executed but results in a null pointer exception:
    <servlet-mapping>
            <servlet-name>HelloWorld</servlet-name>
            <url-pattern>/ </url-pattern>
    </servlet-mapping>      **************************************************
    Robin

    This problem was resolved.
    In hello.jsp
    ACTION="servlet/jservlets.HelloWorld">
    was replaced with
    ACTION="servlet/HelloWorld">
    Robin

Maybe you are looking for