Tomcat 4 as service plus invoke servlet on startup

Hi all. My two questions are as follows, any feedback is much appreciated.
1st)
I wish to run tomcat as a service where it will start automatically on startup plus you can restart it from the win 2000 service console. I have followed the advice on the following link http://www.prabhums.org/weblogs/?postid=237 which places an entry into the service console but doesn't start or stop tomcat as required.
2nd)
On tomcat startup I wish to invoke a servlet when the service starts. Where would I config this and any parameters etc? web.xml?
Thanks in advance
Tas

It's very simple to have a servlet startup. Just use the load-on-startup element in your wbe.xml when you define the servlet.
<servlet>
   <servlet-name>MyServlet</servlet-name>
   <servlet-class>com.kcole.mypackage.MyServlet</servlet-class>
   <load-on-startup>1</load-on-startup>
</servlet>Use a different number. I believe the numbers indicate order of startup.
We use them to mainly to start processes/threads that run at an interval, like a TimerTask for example. We use them for things like setting up our custom connection pool and setting up jobs such as checking directories for files to import, etc.
As to what the request and response objects contain, I don't think there are any. The servlet spec doesn't say regarding this when using the load-on-startup. It runs the init() method.
Karl

Similar Messages

  • Error 404 invoking servlet in tomcat

    OK Im new in this and I have searched the forums and do most of the answers but I cant make my servlet to work. So here is how I have my structure
    MEDEX \ WEB-INF -> all JSP files
    MEDEX \ WEB-INF \ classes -> all CLASS files
    MEDEX \ WEB-INF \ servlet -> SERVLET CLASS FILE
    I have a page called index.jsp that invokes the servlet by a form like this:
    <form name="form1" method="post" action="http:\\localhost:80\Medex\WEB-INF\servlet">
    this is what I have in my web.xml
    <display-name>Servlet SvMedex</display-name>
    <servlet>
    <servlet-name>SvMedex</servlet-name>
    <servlet-class>SvMedex</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>SvMedex</servlet-name>
    <url-pattern>http:\\localhost:80\Medex\WEB-INF\servlet</url-pattern>
    </servlet-mapping>
    <-- <resource-ref>
    <res-ref-name>http:\\localhost:80\Medex\WEB-INF\bd</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>-->
    </web-app>
    I dont have a server.xml since I edited the server.xml in tomcat/conf to evoke anonimous servlets... that will be while I test
    PLease IM DESPERATE ! any help is really appreciated.

    <url-pattern>http:\\localhost:80\Medex\WEB-INF\servle
    t</url-pattern>URL patterns are specified relative to the webapp. If you use a url-pattern of /SvMedex, your servlet will be available at http://localhost:80/Medex/SvMedex

  • Tomcat as service : install path with spaces

    I'm trying to install tomcat as service
    but when I choose an install path with spaces
    I mean smthing like "c:\program files\tomcat"
    it doesn't work
    I tried to modify the wrapper.properties file
    with "" but it doesn't work
    I even set the parameter wrapper.cmd_line with
    a command line that works when launched for CMD
    but the service doesn't start
    any idea????

    I found it ! (hope it helps)
    wrapper.properties that works with spaces in the name
    of the java directory and the tomcat directory
    # $Header: /home/cvs/jakarta-tomcat/src/etc/Attic/wrapper.properties,v 1.2.2.1 2000/10/16 01:59:22 larryi Exp $
    # $Revision: 1.2.2.1 $
    # $Date: 2000/10/16 01:59:22 $
    # jk_service.properties - a bootstrup file for the Tomcat NT service.
    # This file provides jk_nt_service with the needed information to
    # start tomcat at a different process.
    # As a general note, the characters $( and ) are used internally to define
    # macros. Do not use them!!!
    # Whenever you see a set of lines such as:
    # x=value
    # y=$(x)\something
    # the final value for y will be value\something
    # Normaly all you will need to modify is the first two properties, i.e.
    # wrapper.tomcat_home and wrapper.java_home. Most of the configuration
    # is derived from these two.
    # wrapper.tomcat_home should point to the location where you
    # installed tomcat. This is where you have your conf, webapps and lib
    # directories.
    wrapper.tomcat_home=C:\Program Files\tomcat-3.2.1
    # wrapper.java_home should point to your Java installation. Normally
    # you should have a bin and lib directories beneath it.
    wrapper.java_home=C:\Program Files\JavaSoft\JRE\1.3
    #------ ADVANCED MODE ------------------------------------------------
    # Make sure that you read the how-to before making too many changes.
    # Defining where the service is going to put the standard
    # output of Tomcat. This is where System.out.println and
    # System.err.println goes to.
    wrapper.stdout=$(wrapper.tomcat_home)\logs\jvm.stdout
    wrapper.stderr=$(wrapper.tomcat_home)\logs\jvm.stderr
    # Additions to the path. put here directories where you store DLLs for
    # native methods etc.
    wrapper.ld_path=d:\
    wrapper.ld_path=c:\
    # Defining the classpath. All the rows that belongs to the class_path
    # property are concatenated to create the classpath for Tomcat.
    # If you have additional locations that you would like to add to the
    # claspath you should add a new wrapper.class_path=<location> line.
    wrapper.class_path="$(wrapper.tomcat_home)\classes"
    wrapper.class_path="$(wrapper.tomcat_home)\lib\jaxp.jar"
    wrapper.class_path="$(wrapper.tomcat_home)\lib\parser.jar"
    wrapper.class_path="$(wrapper.tomcat_home)\lib\webserver.jar"
    wrapper.class_path="$(wrapper.tomcat_home)\lib\servlet.jar"
    wrapper.class_path="$(wrapper.tomcat_home)\lib\jasper.jar"
    # This is where Javac is located in JDK1.2.x
    wrapper.class_path="$(wrapper.java_home)\lib\tools.jar"
    # and a tribute to JDK1.1.x
    wrapper.class_path="$(wrapper.java_home)\lib\classes.zip"
    # This is the Java interpreter used for running Tomcat
    wrapper.javabin=$(wrapper.java_home)\bin\java.exe
    # This is Tomcat's startup class (the class that contains Tomcat's
    # starting point.
    wrapper.startup_class=org.apache.tomcat.startup.Tomcat
    # This is the location where tomcat's server.xml configuration file
    # is located.
    wrapper.server_xml=$(wrapper.tomcat_home)\conf\server.xml
    # The NT service uses AJP12/AJP13 to shutdown Tomcat. The
    # wrapper.shutdown_port tells the service the identity of the port that
    # is used by AJP12/AJP13.
    wrapper.shutdown_port=8007
    # Can either be ajp12 or ajp13 depending on your configuration.
    # Default value is ajp12
    wrapper.shutdown_protocol=ajp12
    # This is the command line that is used to start Tomcat. You can add extra
    # parameters to it but you can not remove anything.
    wrapper.cmd_line="$(wrapper.javabin)" -classpath $(wrapper.class_path) $(wrapper.startup_class) -config "$(wrapper.server_xml)" -home "$(wrapper.tomcat_home)"

  • Tomcat can't find the servlets!

    Hi!
    I've just installed tomcat tomcat-5.5.16 with apache. Tomcat runs ok. It shows some samples (delivered with tomcat) under www.mywebsite.com/servlets-example and also www.mywebsite.com/jsp-examples. JSP files work perfectly, but when I try the servlets it can't find them:
    www.mywebsite.com/servlets-examples/servlet/RequestHeaderExample Object not found!my classpath lokks like this:
    /opt/SUNWappserver/jdk/lib:/opt/apache-tomcat/common/lib/servlet-api.jar:/opt/apache-tomcat/bin:/opt/apache-tomcat/webapps/servlets-examples/WEB-INF/classes:/opt/apache-tomcat/webapps/ROOT/WEB-INF/classesand web.xml looks like this:
        <servlet>
            <servlet-name>invoker</servlet-name>
            <servlet-class>
              org.apache.catalina.servlets.InvokerServlet
            </servlet-class>
            <init-param>
                <param-name>debug</param-name>
                <param-value>0</param-value>
            </init-param>
            <load-on-startup>2</load-on-startup>
        </servlet>and
        <!-- The mapping for the default servlet -->
        <servlet-mapping>
            <servlet-name>default</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>
        <!-- The mapping for the invoker servlet -->
        <servlet-mapping>
            <servlet-name>invoker</servlet-name>
            <url-pattern>/servlet/*</url-pattern>
        </servlet-mapping>I changed the web.xml und conf and under WEB-INF.
    I also changed server.xml to make tomcat work with apache on port 80.
    What did I do wrong? What did I forget?
    What is the difference between web.xml under conf and the ones under WEB-INF?
    Thanks for any help.

    opt/SUNWappserver/jdk/lib:/opt/apache-tomcat/common/lib/servlet-api.jar:/opt/apache-tomcat/bin:/opt/apache-tomcat/webapps/servlets-examples/WEB-INF/classes:/opt/apache-tomcat/webapps/ROOT/WEB-INF/classes
    May be ur classpath will be wrong try the classpath like this
    ;C:\Tomcat5\common\lib\servlet-api.jar;C:\Tomcat5\common\lib\jsp-api.jar;C:\Tomcat5\common\lib\log4j-1.2.9.jar;C:\Tomcat5\common\lib\mysql-connector-java-3.1.8-bin.jar;hello
    Check out all the enteries in the web-xml file and the path in the environment variable i your system.

  • Tomcat 5 service won't start under w2k

    Has anyone else had trouble getting the Tomcat 5 service to start under Windows 2000 or Windows XP? I have tried installing the service using the installer .exe and also manually by downloading the zip file and using the service.bat file in the bin directory. I can install the service, but when I attempt to start it I receive the following message:
    Could not start the Apache Tomcat service on Local Computer.
    Error 1053: The service did not respond to the start or control request in a timely fashion.
    I have set the JAVA_HOME and CATALINA_HOME environment variables properly. I can start and stop Tomcat just fine by using startup.bat and shutdown.bat. If I can start Tomcat by using startup.bat, what is stopping me from starting it as a service? I must be missing some configuration setting or something...
    I am having the same problem on 3 different computers, 2 w2k machines and 1 XP Pro machine. I have tried both Tomcat 5.0.18 and 5.0.19, same result on both.
    Any help would be appreciated!

    run regedit in command line,add the key:
    [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment]
    "CurrentVersion"="1.4"
    [HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.4]
    "JavaHome"="C:\\Program Files\\Java\\j2re1.4.1_01"
    "MicroVersion"="1"
    "RuntimeLib"="C:\\Program Files\\Java\\j2re1.4.1_01\\bin\\client\\jvm.dll"

  • Tomcat as service - (depend on service)

    hi there!
    we run tomcat as service like other services.
    the tomcat depends on an oracle service. if we shutdown the server, the oracle should start first, and when the oracle is ready, then the tomcat should start. the problem is, that the oracle begins starting before the tomcat runs, but the starting of the tomcat is much faster than the starting of the oracle, so that the tomcat can't read data out of the oracle. we worked with the "depends on service", but this looks only, that they "begin" to start in the right order...
    well now my question: how can i configure the service, that the tomcat starts only then, when the oracle has finished the starting.
    thx
    herwig

    I assume this answer is a little bit outdated, anyway...
    You may tune the windows services with an own priority in order to set the priority lower for the service to start after the one with higher priority.
    As second chance you may also set the second service to try to startup 'n' times before failure, assuming that in the meanwhile the first service should start up. After 'n' unsuccesful tries you may also start a script to force the first service to start and then start the second one.
    But try the first tip.
    Ciao.

  • Tomcat can't find my servlets

    Whenever i try to access one of my servlets via http://localhost:8080/photodb/servlet/dtic.photodb.webapp.PhotoList, I get a 404 error. I am using Tomcat 4.1.12, but i had no troubles in 4.1.10. Does Tomcat 4.1.12 require special configuration, or could something else be the cause of this problem?
    Thanks in advance
    Ryan

    Hi,
    Tomcat 4.1.12 has a bug fix done on the InvokerServlet. The InvokerServlet is responsible for serving the servlet requests. In all the previous versions the InvokerServlet will be enabled by default. In the latest version, it is commented out. You will have to uncomment this for your servlets to be serverd. The changes needs to be done in the <tomcat_home>/conf/web.xml file.
    Uncomment the following lines
    <servlet-mapping>
    <servlet-name>invoker</servlet-name>
    <url-pattern>/servlet/*</url-pattern>
    </servlet-mapping>
    More details regarding the bug and the fix can be found at the following url
    http://online.securityfocus.com/archive/1/292936/2002-09-21/2002-09-27/0
    Thanks
    Shanmugam.PL
    Whenever i try to access one of my servlets via
    http://localhost:8080/photodb/servlet/dtic.photodb.weba
    p.PhotoList, I get a 404 error. I am using Tomcat
    4.1.12, but i had no troubles in 4.1.10. Does Tomcat
    4.1.12 require special configuration, or could
    something else be the cause of this problem?
    Thanks in advance
    Ryan

  • Using ejb service from a servlet in Weblogic 6.0sp1

              anybody had sucess using ejb service from a servlet in Weblogic
              6.0sp1 ?
              It worked in Weblogic 6.0. But in 6.0sp1, the servlet startup always
              return me "ClassCastException"
              when narrowing a lookup of an ejbHome to the specific class.
              Using this same ejb service from a standalone Java client wotked
              fine in both versions.
              Any body has aby clue ?
              Help greatly appreciated
              hyliu
              

    The ejbc'ed jar needs to be in the CLASSPATH of the servlet server.
              Gene
              "Haiyang Liu" <[email protected]> wrote in message news:3ab2670c$[email protected]..
              >
              > anybody had sucess using ejb service from a servlet in Weblogic
              > 6.0sp1 ?
              >
              > It worked in Weblogic 6.0. But in 6.0sp1, the servlet startup always
              > return me "ClassCastException"
              > when narrowing a lookup of an ejbHome to the specific class.
              > Using this same ejb service from a standalone Java client wotked
              > fine in both versions.
              >
              > Any body has aby clue ?
              >
              > Help greatly appreciated
              >
              > hyliu
              >
              

  • How to configure IIS webserver with weblogic so that I can invoke servlets without the .wlforward extension

    How to configure IIS webserver with weblogic so that I can
    invoke servlets without the .wlforward extension
    As per the documentation iisforward.dll is registered as a filter and .wlforward
    has also been
    included as a special file type. However this requires me to key-in ".wlforward"
    after my servlet name.
    What I want is something like this
    http://iis/MyServlet
    Please help me find a solution to this
    Thanks,
    Rishi

    I am able to invoke the servlet without the wlforward extension now.
    However, now I am required to add /weblogic before the servlet
    name otherwise it does not execute the pathtrim property.
    I have tried with the pathprepend thing also.
    Can we get rid of the /weblogic part also. I just want to execute
    my servlet as http://iis/myServlet.
    Your help in this regard is greatly appreciated...
    Thanks..
    "Rishi" <[email protected]> wrote:
    >
    Thanks for the reply Kumar.
    I did follow the instructions as given in the Weblogic documentation
    The documentation said to add iisforward.dll as a filter service
    and register .wlforward as a special
    file type to be handled by iisproxy.dll. For this,
    while configuring the IIS server in the Home Directory tab
    I added an extension ".wlforward" and the executable as
    iisproxy.dll. Is this the way it should have been done...
    I also modified the iisproxy.ini file as per the documentation.
    I have added the WLForwardPath property and set it to /weblogic.
    My server works fine when I give the url as
    http://iis/myServlet.wlforward
    but it does not work for
    http://iis/myServlet and this is the way i'd want it to work.
    Please tell me if I am missing something on the configuration part
    and if there is something special that needs to be done. I shall
    be grateful to you.
    Kumar Allamraju <[email protected]> wrote:
    http://e-docs.bea.com/wls/docs61/adminguide/isapi.html#101184
    Rishi wrote:
    How to configure IIS webserver with weblogic so that I can
    invoke servlets without the .wlforward extension
    As per the documentation iisforward.dll is registered as a filter
    and
    .wlforward
    has also been
    included as a special file type. However this requires me to key-in".wlforward"
    after my servlet name.
    What I want is something like this
    http://iis/MyServlet
    Please help me find a solution to this
    Thanks,
    Rishi

  • Re: How do I invoke Servlets...continued

    Hi Howard,
              Could you show us web.xml?
              Regards,
              Slava Imeshev
              "Howard Hyde" <[email protected]> wrote in message
              news:3ccedf8a$[email protected]..
              > My posting appears to have been truncated, so here is the remainder:
              > (continued)
              > 'Pilot' is a servlet defined and mapped in my web.xml file. But when I
              attempt
              > to invoke the servlet in the app with any of the following:
              > http://localhost:7001/pilots/Pilot
              > http://localhost:7001/pilots/pilot
              > http://localhost:7001/pilots/servlet/Pilot
              > http://localhost:7001/pilots/servlet/pilot
              >
              > ... I get a 404 error.
              >
              > However, the following JSP, which is part of the same web application
              component
              > of the Enterprise app, works:
              > http://localhost:7001/pilots/Rating.jsp
              >
              > So the question of the day once again, is:
              >
              > How do I invoke servlets in an enterprise application?
              >
              > Best regards,
              >
              > Howard
              > 818-366-2686
              

    and to add to matt's post:
              in the servlet init() method trace out some debug to ensure that new
              versions of your servlet are actually being deployed:
              ..init() {
              System.out.println( getServletName() + " was deployed at " + " new
              Date(System.currentTimeMillis()) );
              "Matt Krevs" <[email protected]> wrote in message
              news:[email protected]...
              > 1. What stack trace do you receive, if any, when your call to your servlet
              > doesnt work
              >
              > 2. Is your servlet in a package? If it is then you need to specify the
              > package in the servlet-class element
              >
              > 3. Is it possible that your servlet-name and/or servlet-class elements in
              > web.xml have some spaces in them? Maybe you should remove the line feeds
              > etc. and specify your servlet elements as you have your servlet-mapping
              > elements
              >
              > eg like this
              >
              > <servlet>
              > <servlet-name>Pilot</servlet-name>
              > <servlet-class>FrmPilot2</servlet-class>
              > <load-on-startup>0</load-on-startup>
              > </servlet>
              >
              > 4. Do you get any deployment errors when weblogic starts up?
              >
              > 5. Try setting the load-on-startup parameter to a positive number. You may
              > receive a helpful? stacktrace when weblogic starts up
              >
              >
              > "Howard Hyde" <[email protected]> wrote in message
              > news:[email protected]...
              > > The following are EXCERPTS from the web.xml file:
              > >
              > > <web-app>
              > > <servlet>
              > > <servlet-name>
              > > Pilot
              > > </servlet-name>
              > > <servlet-class>
              > > FrmPilot2
              > > </servlet-class>
              > > <load-on-startup>
              > > 0
              > > </load-on-startup>
              > > </servlet>
              > > <servlet-mapping>
              > > <servlet-name>Pilot</servlet-name>
              > > <url-pattern>/Pilot</url-pattern>
              > > </servlet-mapping>
              > >
              > > </web-app>
              > >
              > >
              >
              >
              

  • Invoker servlet

    Hi,
    I am interested in knowing why we should avoid invoker servlets?
    what are short comings of invoker servlet?
    ( Yes for invoker servlets completer path up to servlet is to be given)
    Thanks

    The Invoker servlet is a built int servlet mapped such that allows you to invoke any servlet by using the URL: /servletPackage/servletClassName. While this is good to get started and to know, you should never use it in a production environment.
    If you give password protected access to a folder, say Employees and map a servlet to /Employees/MyServlet, the servlet is also protected. Only people with the authorized username/password combinations can run the servlet. But if you allow the default mapping with the Invoker servlet, then the same servlet will also be accessible to everyone as /servlet/MyServlet in which case your authorization fails and everyone has access to your servlet's functionality, potentially modifying data etc.
    This is only the authorization aspect. Other than this, the Invoker servlet makes it hard for you to hide your actual package/ classnames. Other features like init parameters and filters are also not possible in this case.
    This is why you should NOT use the Invoker servlet. Even the Tomcat FAQ says you should not.
    Read more here:
    [1] http://faq.javaranch.com/view?InvokerServlet
    [2] http://jakarta.apache.org/tomcat/faq/misc.html#evil
    P.S. a_joseph also had a valid point and he gave you the same link also.
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Web service proxy and servlet

    Hi,
    i use jdev 10.1.3.4 and i follow the tutorial "developping,depoying and managing web services using jdeveloper.
    I try to use the proxy for the web service from a servlet like in the main method of the proxy :
    HelloSoapHttpPortClient myPort = new HelloSoapHttpPortClient();
    System.out.println("calling " + myPort.getEndpoint());
    System.out.println(myPort.sayHello("didier823"));
    and i got this error :
    10/03/10 16:58:02 not an interface: services1.Hello
    How can use the proxy generated by jdev from a servlet or a jsp ?
    Thank you for your help !

    Hi,
    i find a solution i regenered a new proxy with another package and it works fine
    i can use the proxy from my servlet to call the ejb web service.
    Bye.

  • No response port in routing service, when invoking Asynchronus BPEL process

    Hi All,
    I have a routing service and invoked an asynchronous BPEL process through SOAP invocation service. I have mentioned as Asynchronous process in the routing service. But I don't see any port for the response message.
    I need the response message from BPEL to do someother process in ESB.
    Regards
    Jude.

    Hi Jude,
    I don't think that's possible that way. Since BPEL can be used for long-running processes -possibly containing human workflow- the ESB flow would need to have a lifespan at least as long. You could achieve the same by having the BPEL process publish the outcome via JMS, and have another ESB flow subscribe to the JMS topic. Or invoke another ESB directly from the BPEL process.
    Regards, Ronald

  • Service method  of servlet  is called repetitively as response time is more

    Problem: when we try to retrieve data for a particular input, then the retrieve
    query takes longer time which is as expected i.e more than five minutes as our data ware house is large and the where clause is very complex. After 5 mins what happens is that the service
    method in the servlet call is made again and so the retrieve process as if it was
    triggered again,where as no one has triggered it. This happens every 5 mins and the overall
    process hangs forever.pl help if any answer
    thanks in adv.
    M.S.Chandrasekhar

    Hi ,
    Hello ,
    Try this code ,
    Class classObject = Class.forName("SecondServlet");
    SecondServlet servlet = (SecondServlet)classObject.newInstance();
    servlet.init(getServletConfig());
    System.out.println("Before calling the service() from TestServlet");
    servlet.service(req,res);
    servlet.destroy();
    Regards ,
    Venkat

  • Tomcat 5 con pool, Oracle, servlet error on Connection ocon = ds.getConnect

    Hello,
    I am trying to create a connection pool to my Oracle db using the documentation provided for
    Tomcat 5. In the servlet shown below, the servlet fails at this line:
    Connection ocon = ds.getConnection();
    The servlet stops with no error message. Also, I'm not sure what is supposed to go in
    this line:
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    which may be where the real problem begins. Any suggestions are greatly appreciated.
    Here is the servlet:
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.Date;
    import java.text.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class CraigsMain extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // Process the http Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
    try {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/CraigsList");
    Connection ocon = ds.getConnection();
    String sql = "select formtitle from checkboxforms where cbformid = 157";
    PreparedStatement pStmt = ocon.prepareStatement(sql);
    ResultSet rs1 = pStmt.executeQuery();
    rs1.next();
    out.println("<br><br><br>" + rs1.getString(1) + "<br>");
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException sqln) {
    System.err.println("naming exception error: " + sqln);
    // A post request calls the get request because they do the same thing
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    Thank you,
    Logan

    Hello,
    I am trying to create a connection pool to my Oracle db using the documentation provided for
    Tomcat 5. In the servlet shown below, the servlet fails at this line:
    Connection ocon = ds.getConnection();
    The servlet stops with no error message. Also, I'm not sure what is supposed to go in
    this line:
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    which may be where the real problem begins. Any suggestions are greatly appreciated.
    Here is the servlet:
    package CraigsClasses;
    import javax.servlet.*;
    import javax.servlet.jsp.*;
    import java.net.*;
    import java.util.*;
    import java.io.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.util.Date;
    import java.text.*;
    import javax.naming.*;
    import javax.sql.DataSource;
    public class CraigsMain extends HttpServlet {
    public void init(ServletConfig config) throws ServletException {
    super.init(config);
    // Process the http Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response)
         throws ServletException, IOException {
    try {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    Context initContext = new InitialContext();
    Context envContext = (Context)initContext.lookup("java:/comp/env");
    DataSource ds = (DataSource)envContext.lookup("jdbc/CraigsList");
    Connection ocon = ds.getConnection();
    String sql = "select formtitle from checkboxforms where cbformid = 157";
    PreparedStatement pStmt = ocon.prepareStatement(sql);
    ResultSet rs1 = pStmt.executeQuery();
    rs1.next();
    out.println("<br><br><br>" + rs1.getString(1) + "<br>");
    } catch(SQLException sqle) {
    System.err.println("sql exception error: " + sqle);
    } catch(NamingException sqln) {
    System.err.println("naming exception error: " + sqln);
    // A post request calls the get request because they do the same thing
    public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    doGet(request, response);
    Thank you,
    Logan

Maybe you are looking for