Invoking servlet from server (tomcat 5.5) at regular interval

Hi all
My problem is I want to send mail on 1st day of every month through form my application. But for that I don�t want to login my application. It should fire automatically from server. I am using Tomcat 5.5 for my application. This process also involved talking to database.
Is there any to achieve this?
Please help me.
Thanks in advance.

these are the results of the "servlet context listener" key on google.
http://edocs.bea.com/wls/docs70/webapp/app_events.html
http://publib.boulder.ibm.com/infocenter/wasinfo/v5r1//index.jsp?topic=/com.ibm.websphere.base.doc/info/aes/ae/rweb_listeners.html
Regards,
Sebastien Degardin

Similar Messages

  • Cannot invoke servlet from JSP

    I am trying to invoke a servlet from my JSP file. At present I am getting the error:
    500 Internal Server Error
    java.lang.IllegalArgumentException: Resource /servlet/CreateSPSS not found
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.EvermindPageContext.forward
    I understand that my JSP cannot find my servlet but I cannot identify what the correct path or amendment is.
    My JSP file is located in:
    default-web-app/examples/jsp/com.xml2spss.jsp
    In the JSP my forward parameter is :
    <jsp:forward page="/servlet/CreateSPSS" />
    and my servlet (.java & .class) is located in
    default-web-app/WEB-INF/classes/com/pmstation/spss/site/servlet.CreateSPSS.java
    I have added the following line to Web.XML:
    <servlet-mapping>
    <servlet-name>CreateSPSS</servlet-name>
    <url-pattern>/servlet/CreateSPSS</url-pattern>
    </servlet-mapping>
    Where am I going wrong??
    Thankyou for any help at all on this one.

    Shaun,
    Nice to know that you find a way that works. However, what Zsolt suggests should work; otherwise, it is a bug. That is, put the servlet definition and servlet mapping in your web.xml and then you should be able to access http://host:port/myWebContext/servlet/CreateSPSS?myParmName=myParm without seeing a response like "No resource found". Please make sure that your servlet definition come before the corresponding servlet mapping.

  • Invoking servlet from mDB

    Hi all;
    this is the process.
    1. Servlet received / creates msg.
    2. Servlet Enqueues Msg on JMS queue.
    3. MDB dequeues.
    -- processes against DB
    -- composes respoonse.
    4. mdb invokes servlet with response.
    servlet need not maintain state.
    State information can be passed in Msg (Query and Response)
    I was just wanting to find out if this possible in oc4j.
    apparently, there is a process in weblogic 6.1 to support this.
    Any help is appreciated.
    thanks.
    jayant

    I would assume that you would need to do a "createSipApplicationSession" on your sip factory and then get the ID from there.
    Then create a request from your session and send it.
    Wouldn't you want each outgoing call to be associated with a different sip app session?

  • Error in invoking servlet from JSP

    Hi - again!
    after being thoroughly reprimanded for posting on the wrong board, and hence seeing the error in my ways, all help greatly appreciated....
    I have read elsewhere that it is possible to call a servlet (which produces HTML) from within a JSP, thus keeping a nice clean MVC paradigm and making it easier for non-java people to design the front-end.
    I am having difficulty getting it to work and any help is much appreciated:
    My servlet (Mole):
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
            response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
            try {
                out.write("###some html stored in DB#####");
            } finally {
                out.close();
        }my JSP:
    <jsp:include page="Mole" flush="false"></jsp:include>the error I get
    Internal error flushing the buffer in release()
    StandardWrapperValve[jsp]: PWC1406: Servlet.service() for servlet jsp threw exception
    java.io.IOException: Stream closed
            at org.apache.jasper.runtime.JspWriterImpl.ensureOpen(JspWriterImpl.java:257)
            at org.apache.jasper.runtime.JspWriterImpl.clearBuffer(JspWriterImpl.java:206)
            at org.apache.jsp.CMS.services_jsp._jspService(services_jsp.java from :176)
            at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:93)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:470)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:364)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
            at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
            at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:288)
            at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:271)
            at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:202)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94)
            at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632)
            at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577)
            at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571)
            at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080)
            at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:272)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568)
            at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263)
            at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214)
            at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380)
            at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265)
            at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)Any pointer as to what I am donig wrong?
    many thanks

    in your web.xml
    <servlet>
    <servlet-name>Mole</servlet-name>
    <servlet-class>srvlt.Mole</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Mole</servlet-name>
    <url-pattern>/Mole</url-pattern>
    </servlet-mapping>
    package srvlt;
    // Import servlet packages
    import javax.servlet.*;
    import javax.servlet.http.*;
    // Import other Java packages
    import java.io.*;
    public class Mole extends HttpServlet {
            public void init() throws ServletException {}
            public void doGet(HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
                response.setContentType("text/html;charset=UTF-8");
                PrintWriter out = response.getWriter();
                try {
                    out.write("###some html stored in DB#####");
                } finally {
                    out.close();
    }in your jsp
    <jsp:include page="/Mole" flush="false"></jsp:include>

  • Syntax for invoking servlet from form in a servlet context

              Hi all,
              I have a web application called A, put all related files in a directory B. I deployed
              some JSPs into a directory C under B. Within a jsp called c.jsp in C, a servlet
              is called in a form. What syntax should I use to call the servlet properly. For
              the given web application A, the url syntax for it is http://server/A/C/c.jsp.
              I used 'action=servlet', 'action=/servlet', but failed. For 'action=servlet',
              the user is directed to http://server/A/C/servlet. The other is http://server/servlet.
              Both are not correct. Any ideas?
              Thanks,
              Lijun
              

    What is the servlet-mapping in the web.xml file? If this is your servlet mapping:
              <servlet>
              <servlet-name>CookieCounter</servlet-name>
              <servlet-class>examples.servlets.CookieCounter</servlet-class>
              </servlet>
              <servlet-mapping>
              <servlet-name>CookieCounter</servlet-name>
              <url-pattern>monster</url-pattern>
              </servlet-mapping>
              Then the appropriate action is action=monster (or possibly action=../monster).
              Hope this helps,
              Robert
              Lijun wrote:
              > Hi all,
              >
              > I have a web application called A, put all related files in a directory B. I deployed
              > some JSPs into a directory C under B. Within a jsp called c.jsp in C, a servlet
              > is called in a form. What syntax should I use to call the servlet properly. For
              > the given web application A, the url syntax for it is http://server/A/C/c.jsp.
              > I used 'action=servlet', 'action=/servlet', but failed. For 'action=servlet',
              > the user is directed to http://server/A/C/servlet. The other is http://server/servlet.
              > Both are not correct. Any ideas?
              >
              > Thanks,
              > Lijun
              

  • Invoking servlet from ODB using GET

    I have a requirement where i need to invoke a servlet using GET. Can anyone let me know the procedute to follow in this invocation.
    Your help is appreciated
    Thanks,
    P

    Hi
    Try the following way to register servlets in web.xml
      <web-app>
        <servlet>
            <servlet-name>generateSurveyServlet</servlet-name>
            <servlet-class>com.robbie.servlet.generateSurveyServlet</servlet-class>
       </servlet>
          <servlet-mapping>     
                  <servlet-name>generateSurveyServlet</servlet-name>
                  <url-pattern>/generateSurveyServlet </url-pattern>
            </servlet-mapping>
    <servlet>
            <servlet-name>surveyResultsHandlerServlet</servlet-name>
            <servlet-class>com.robbie.servlet.surveyResultsHandlerServlet</servlet-class>
       </servlet>
          <servlet-mapping>     
                  <servlet-name>surveyResultsHandlerServlet</servlet-name>
                  <url-pattern>/surveyResultsHandlerServlet </url-pattern>
            </servlet-mapping>
    </web-app>i hope this will clear u.
    thanks,
    nvseenu

  • Cann't invoke servlet from my own browser

    Hi Techies,
    I have my written browser , which can invoke the www pages, but when i try to invoke my servlet , it doesn't show me the desired page and output like
    <?xml version1.0
    (which is starting of deployment , web.xml file)
    Can anybody give some tips/suggestions??
    Many thanks in advance....
    Vaibhs

    Yes the file which is responsible for deployment is the web.xml file.If you do not mind send me this file to check it.It can be an error in the Context TAG.

  • How to pass parameters/atrributes to Servlet from ALBPM

    HI Friends,
    I am invoking servlet from bpm using server configuration, i am able to invoke servlet, but not able to pass parameters dynamically,
    Also I like to receive response parameters/attributes from servlets?
    Can any body help me on this?
    Look forward for response.
    Cheers

    Some helpful Docs on the WebServer component for you:
    The WebServer component is used to send HTTP requests to an HTTP server and capture the responses. It supports HTTP methods GET and POST.
    The body of the HTTP response is available in the WebServer.response attribute (String).
    Note: This component is superseded by the Fuego.NetX.AdvancedWebServer component, which provides better performance and more functionality like support for proxies and for more HTTP methods (like PUT and DELETE).
    Example: Get Oracle's website home page and save it to a file.
    getFrom(WebServer, url : "http://oracle.com", args : null)
    binaryResponse = Binary(text: WebServer.response,
    encoding: "UTF8")
    BinaryFile.writeFromBinaryTo(data : binaryResponse,
    name : "/tmp/oracle_index.html",
    append : false)

  • Calling servlet from java page flow

    Hi,
    I need to call servelt class from the <netui:anchor ..> tag of my jpf.
    i have mapped this servlet class in the web.xml.
    please tell us how to invoke servlet from the netui:anchor tag from the jpf action
    method.
    thanks
    shashi

    I am calling a Servlet from JAVA Class as I am using IDE: Eclipse. The Problem is below
    URL url = new URL(ServletPath);
    URLConnection connet = url.openConnection();Why should the Servlet running in different Runtime print on your Eclipse Runtime. Please be more clear about the question.

  • Return zip file as soap attachment  from server..

    Dear Friends,
    Requirement:
    I would like to download a zip file from server(tomcat) with soap attachment using wsdl.
    I have tried googling but didn't get exact information and samples on this.
    Please help me on this and it would be helpful if u can provide me one sample on this.
    Thanks in advance.
    Cheers
    Cap

    pls http://www.catb.org/~esr/faqs/smart-questions.html#writewell
    How To Ask Questions The Smart Way
    Eric Steven Raymond
    Rick Moen
    Write in clear, grammatical, correctly-spelled language
    We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding (often enough to bet on, anyway). Answering questions for careless and sloppy thinkers is not rewarding; we'd rather spend our time elsewhere.
    So expressing your question clearly and well is important. If you can't be bothered to do that, we can't be bothered to pay attention. Spend the extra effort to polish your language. It doesn't have to be stiff or formal - in fact, hacker culture values informal, slangy and humorous language used with precision. But it has to be precise; there has to be some indication that you're thinking and paying attention.
    Spell, punctuate, and capitalize correctly. Don't confuse "its" with "it's", "loose" with "lose", or "discrete" with "discreet". Don't TYPE IN ALL CAPS; this is read as shouting and considered rude. (All-smalls is only slightly less annoying, as it's difficult to read. Alan Cox can get away with it, but you can't.)
    More generally, if you write like a semi-literate b o o b you will very likely be ignored. So don't use instant-messaging shortcuts. Spelling "you" as "u" makes you look like a semi-literate b o o b to save two entire keystrokes.

  • Invoke servlet

    How can I invoke servlet from an <af:form> tag ?

    Hi Zaro,
    it depends what you'd like to do.
    1. Put the result into the page: Use normal links, eg. <af:objectImage source="/graphservlet"/>2. Use it as a navigation step: edit your faces-config.xml
    --olaf                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to connect to MS Access from servlet uploaded in TOMCAT server

    Hi,
    I want to access MS Access from servlet .I use TOMCAT server.I want to know what should i do.How to get drivers and how to set class path for them.
    Please help me in finding the solution
    thanks and Regards

    HI,
    try this
    <Code>
    response.setContentType(CONTENT_TYPE);
         PrintWriter out = response.getWriter();
         java.sql.DatabaseMetaData dm = null;
         java.sql.ResultSet rs = null;
         try
              Class.forName("sun,jdbc.odbc.JdbcOdbcDriver");
              Connection con = java.sql.DriverManager.getConnection("jdbc:odbc:dsnName","","");
              dm = con.getMetaData();
              out.println("<html>");
              out.println("<head><title>Servlet1</title></head>");
              out.println("<body bgcolor=\"lightblue\">");
              if(con!=null){
                   dm = con.getMetaData();
                   out.println("<B><br>Driver Information</B>");
                   out.println("\n\t<br><br>Driver Name: "+ dm.getDriverName());
                   out.println("\n\t<br>Driver Version: "+ dm.getDriverVersion ());
                   out.println("\n\t<br>Database Information ");
                   out.println("\n\t<br>Database Name: "+ dm.getDatabaseProductName());
                   out.println("\n\t<br>Database Version: "+ dm.getDatabaseProductVersion());
                   out.println("\n\t<br><br>Avalilable Catalogs ");
                   rs = dm.getCatalogs();
                   while(rs.next()){
                             out.println("<br>\tcatalog: "+ rs.getString(1));
                   out.println("\n\t<br><br>conURL =" + conURL);
                   out.println("\n\t<br><br>Title = Database");
                   rs.close();
                   rs = null;
                   con.close();
              }else {
                   out.println("Error: No active Connection");
         }catch(ClassNotFoundException e) {
              out.println("Coudn't laod the database driver: " + e.getMessage());
         } catch(SQLException e) {     
              out.println("SQLException caught: " + e.getMessage());
              try {
                   if (con != null)
                        con.close();
                   if (rs != null)
                        rs.close();
              catch (SQLException ignored) {}
              finally {
                   try {
                             if (con != null)
                                  con.close();
                             if (rs != null)
                                  rs.close();
                        catch (SQLException ignored) {}
    </Code>
    Sachin

  • Problem in invoking a servlet from another PC

    hi
    i am trying to invoke a servlet running on apache tomcat 5.0.28 from another PC, my j2me wireless toolkit is on one PC and it runs a MIDlet that invokes a servlet on another PC, but am getting an exception connectionNotFound....
    both the computers are on LAN, what do i do?
    Need guidance

    No, i think tomcat server is enough.. have u checked your servlet from browser?
    I got the same error in black berry application and at that time i found that its due to servlet config in web.xml
    Have u configured your servlet in web.xml?
    One suggestion.. change your URL to www.google.com and then run your MIDlet.. it confermed that your midlet is OK
    Http request is fine to send data from your WTK.
    About apache http "NO IDEA"
    Thks

  • How to invoke a servlet from an application-URGENT

    Hi,
              My requirement is as follows :
              I have to invoke a servlet from a client application. I am using
              java.net.URL and java.netURLConnection classes to
              open a connection and invoke the servlet.
              I am using WebLogic5.1
              my code snippet is as follows :
              URL url = new URL("http://localhost:7001/urlservlet");
              URLConnection connection = url.openConnection();
              connection.setRequestMethod("GET");
              connection.setDoOutput(true);
              connection.setDoInput(true);
              PrintStream outStream = new PrintStream( connection.getOutputStream() );
              outStream.print("message=hai");
              outStream.flush();
              outStream.close();
              When I execute the application, Webloigc server console is displaying the
              following line.
              <Listen Thread> Adding Address : <machine name><ip address>
              But the service method of servlet is not getting invoked at all.
              Help me to find the answer.
              Jeelani
              

    jeelani <[email protected]> wrote:
              > Hi Dimitri,
              > Thanks a lot.That worked for me.
              > But if I want to send java objects (Vectors,beans),what is the best way to
              > do it.
              > This is exactly what our requirement is..
              If you want to send Java object you have to use POST:
              URLConnection conn = ...
              conn.setDoOutput(true); // makes this a POST
              OutputStream os = conn.getOutputStream();
              ...write your objects here...
              os.flush();
              os.close();
              InputStream in = conn.getInputStream(); // sends data to the server and
              // opens input stream
              ..read servlet response..
              .. ot just close the stream...
              in.close();
              > my client application need to send some java components to our main server
              > located in our head office.The servlet will read the objects and execute the
              > functionality..
              > I really appreciate for the fast response from you.
              > Dimitri Rakitine <[email protected]> wrote in message
              > news:[email protected]...
              >> Try it like this:
              >>
              >> URL url = new URL("http://localhost:7001/urlservlet?message=hai");
              >> URLConnection connection = url.openConnection();
              >> InputStream in = connection.getInputStream();
              >> in.close();
              >>
              >>
              >> jeelani <[email protected]> wrote:
              >> > Thanks for the quick response.
              >>
              >> > Actually right now it doesn't matter whether it is by GET or by POST.
              >> > Add my clinet application just needs to send data to Servlet and nothing
              > to
              >> > get in return.Thats why I am using connection.getOutputStream().
              >>
              >> > since application will not be reading anything from servlet, I don't
              >> > think it is required to use connection.getInputStream().
              >> > (I am sorry, if I am wrong).
              >>
              >> > Can you please help me out. weblogic server is able to get the address
              >> > from where the request is coming. Only problem is servlet is not getting
              >> > invoked.
              >>
              >> > regards,
              >> > Jeelani
              >>
              >>
              >> > Dimitri Rakitine <[email protected]> wrote in message
              >> > news:[email protected]...
              >> >> Are you trying to do get or post? First you set method to GET
              >> >> and then you do the POST.
              >> >>
              >> >> And add InputStream is = connection.getInputStream() - that will
              >> >> result in HttpURLConnection sending data to the server and getting
              >> >> back the response.
              >> >>
              >> >> jeelani <[email protected]> wrote:
              >> >> > Hi,
              >> >>
              >> >> > My requirement is as follows :
              >> >>
              >> >> > I have to invoke a servlet from a client application. I am using
              >> >> > java.net.URL and java.netURLConnection classes to
              >> >> > open a connection and invoke the servlet.
              >> >>
              >> >> > I am using WebLogic5.1
              >> >>
              >> >> > my code snippet is as follows :
              >> >>
              >> >> > URL url = new URL("http://localhost:7001/urlservlet");
              >> >>
              >> >> > URLConnection connection = url.openConnection();
              >> >>
              >> >> > connection.setRequestMethod("GET");
              >> >> > connection.setDoOutput(true);
              >>
              >> >> > PrintStream outStream = new
              >> > PrintStream( connection.getOutputStream() );
              >> >> > outStream.print("message=hai");
              >> >> > outStream.flush();
              >> >> > outStream.close();
              >> >>
              >> >> > When I execute the application, Webloigc server console is displaying
              >> > the
              >> >> > following line.
              >> >>
              >> >> > <Listen Thread> Adding Address : <machine name><ip address>
              >> >>
              >> >> > But the service method of servlet is not getting invoked at all.
              >> >>
              >> >> > Help me to find the answer.
              >> >>
              >> >> > Jeelani
              >> >>
              >> >> --
              >> >> Dimitri
              >> >> http://dima.dhs.org
              >>
              >>
              >>
              >> --
              >> Dimitri
              >> http://dima.dhs.org
              Dimitri
              http://dima.dhs.org
              

  • 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

  • How  do i  make safari  open instead of chrome when i open a link through  mail?

    Some how i made goggle chrome the defalt browser  when there is a link in my mail. I want safari to be the defalt browser as far as mail is concerned.

  • Nrl digital pass subscribed and paid but no 'active subscription'???

    Hi can someone please help me!!!!!!!! I subscribed to NRL Digital Pass almost 12 months ago and payment has been coming out of my account every week since (including a few days ago). I have tried to access the Digital Pass today to watch the football

  • JDBC and Linguistic Sorting

    The problem: oracle jdbc thin driver doesn't see environment variable NLS_SORT Description: We have a lot of code written in coldfusion and now we would like to switch form CF5 to CFMX. We use oracle thin driver to connect CFMX to oracle DB. The prob

  • Email with Droid and Outlook 07

    Why does some, (not all) of my Email go to both my phone and my Outlook and then some only goes to my phone?  I have everything set to leave the mail on the server, and I've checked and it's still there, so that is not the problem.

  • Graphic Designer - Criteria for a New Computer

    I apologize if I'm not in the right forum, but I can't think of anyone that would know better what I need to look for, than other Adobe users. I may need to purchase a new laptop. As a graphic designer/web designer/video editor, what criteria constit