Calling a servlet program using tomcat...

I have placed a simple servlet(.class) program in my C:\jakarta-tomcat-4.1.24\webapps\ROOT\WEB-INF\classes folder. How should i call that in by browser.
How to set classpath in tomcat for compiling servlets.
THANX

it's depend what port you are using
http://localhost:8080/servlet/yourservletname
http://localhost:80/servlet/yourservletname
if you uncommented out the comment for the servlet invoker in the web.xml found in the conf directory
It looked something 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>
    -->get rid of the <!-- and --> to uncomment the comment out
than you can do
http://localhost:8080/yourservletname
http://localhost:80/yourservletname
Anyway..you should modify you web.xml file found in
C:\jakarta-tomcat-4.1.24\webapps\ROOT\WEB-INF\ folder
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
    "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
  <display-name>Welcome to Tomcat</display-name>
  <description>
     Welcome to Tomcat
  </description>
<servlet>
   <servlet-name>myServlet</servlet-name>
   <servlet-class>HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
   <servlet-name>myServlet</servlet-name>
   <url-pattern>/hi</url-pattern>
</servlet-mapping>
</web-app>then you can do (again..make sure you uncomment out the
http://localhost:8080/hi
http://localhost:80/hi
servlet-name tag is the name of the servlet Tomcat will recognized (can be anything you make up)
servlet-class is the servlet.class file that you want to use
the url-pattern is what you have to type in the url to make a request to the servlet (again this can be anything you would like it to be)
heck..it can even be a * for anything

Similar Messages

  • How to configure a servlet program using Eclipse?

    Hi,
    Am just learning Java and J2ee..Am not efficient..Don't laugh @ my question..
    I installed jdk 1.6, Apache tomcat 5.0 and eclipse 3.2.1 and also installed wtp plugin to work with j2ee perspective of eclipse..I did this in my PC..could U plz tell me what I need to install in addition?
    How come I write my Servlet program using Eclipse...
    Thanq
    Vani.

    This is the Sun Java System Messaging Server forum. Though this application software bears Java in it's name it has nothing to do with the programming language Java.

  • Unable to run Servlet program using J2EE SDK

    Hello,
    i am a newbie to all this j2ee stuff and servlets even.so the problem that i have maybe a very common one and i hope that most of you may have a fix to it...
    i use J2EE SDK to compile and run Servlet programs.I have a Servlet program with the class name defined as
    public class MyServlet extends HttpServlet ....
    the file is stored as MyServlet.java
    i set the CLASSPATH variable so that the required classes for the compilation of the program can be located.
    the program compiles without any glitches.
    However when i run the program by saying
    java MyServlet
    ( i dont think its any different to run servlet code is it?)
    i get the message
    java.lang.NoClassDefFoundException:MyServlet
    Can someone suggest a remedy?
    thank you
    -NDK

    First, I don't understand what you are trying to do. Running a servlet ?
    Servlets are ran by an application server ! (Apache Tomcat ....).
    Second, is your class in any package ?

  • Problem in compiling servlet class - using Tomcat

    Hi,
    I have a servlet pgm that I'm trying to compile.I using Tomcat application server.I have my servlet class in D:\servlet_wrk\project1\src
    and my deployment descriptor in D:\servlet_wrk\project1\etc
    my CLASSPATH var is set to C:\Sun\AppServer\jdk\bin
    and
    my PATH var is set to C:\Sun\AppServer\bin.
    When I compile my servlet class Ch1Servlet.java in the command line from the directory
    D:\servlet_wrk\project1 using the command
    javac -classpath D:\applications\tomcat-5.5.12\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java,
    it says error:cannot read: src/Ch1Servlet.java
    Can somebody help me to solve this problem and help me to compile my servlet class.
    Thanks.

    Thanks...as u said I tried putting dir & found that
    my file was saved as Ch1Servlet.java.txt instead for
    Ch1Servlet.java......So that was a problem.Now I'm
    able to compile.Oh, yeah. Notepad will do that to you. I think when you save in Notepad if you put quotes around the name "Whatever.java" then it won't add the .txt.
    But on compiling I'm getting the following error
    package java.servlet.* does not exist
    package java.servlet.http.* does not exist
    package java.io.* does not exist
    Do u the reason for this??? The servlet stuff is java[b]x.servlet. For the io stuff, I don't know, I'd have to see your code. Either you have a typo or a corrupt installation.

  • Not able to compile servlet pgm - using Tomcat

    Hi,
    I have a servlet pgm that I'm trying to compile.I using Tomcat application server.I have my servlet class in D:\servlet_wrk\project1\src
    and my deployment descriptor in D:\servlet_wrk\project1\etc
    my CLASSPATH var is set to C:\Sun\AppServer\jdk\bin
    and
    my PATH var is set to C:\Sun\AppServer\bin.
    When I compile my servlet class Ch1Servlet.java in the command line from the directory
    D:\servlet_wrk\project1 using the command
    javac -classpath D:\applications\tomcat-5.5.12\common\lib\servlet-api.jar -d classes src/Ch1Servlet.java,
    it says error:cannot read: src/Ch1Servlet.java
    Can somebody help me to solve this problem and help me to compile my servlet class.
    Thanks.

    **MAJOR SPAMMING SCUM BAG ALERT**
    I was puzzled in that you asked a SQL Server question in one post and then in another thread asked a Oracle related question... and then I noticed you had cross posted one of your questions at JavaRanch and I was more annoyed....
    and then I found this....
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=10&t=002447
    You sir -> Michael Byrd -> are a scum sucking dirtbag.
    To quickly explain. Mr. Byrd posts his messages (which he copies wholesale from other posters) so that he can get better google caching for the website listed in his profile.
    This is such scummy behaviour I don't even know what to say. Other than basically everyone that has ever helped you had totally wasted their time.
    You are scum. Your company is scum. I hope you rot in hell.

  • Not calling the event S-O-S while executing the program using T-Code

    Hi All,
    I've a strange problem here in my Quality environment.
    Well,
    The issue is when a program is getting executed from SA38/SE38, its working perfectly as expected. Whereas while calling the same program using the T-Code attached to that then the program is not getting executed.
    While looking at the code through debugger, the start of selection event is getting triggered while executing the program through SA38/SE38 where as the S-O-S event is not getting triggered if its through the T-Code. And this is happening ONLY with Quality environment.(In Dev and in Prod its working perfectly either through T-Code or thru SA38).
    I tried activating all the objects again for that program(Including the T-Code) through SE80, Still no luck.
    Please thow some light on it to eradicate this error in Quality Env.
    Thanks for all your help.
    Regards,
    -Shankar.

    Hi Shankar,
    please check the transaction definition and make sure you defined a [report transaction|http://help.sap.com/saphelp_nw73/helpdata/en/43/132f9803d76f40e10000000a422035/frameset.htm]
    If you noticed a difference between Quality, Dev and and Prod environment, probably the transaction definition or the program is not the same.
    Check version history for all objects involved.
    Regards,
    Clemens

  • Urgent!!!!!!!!!!Calling a servlet setting cookie

    Hi,
         The following is the complete picture of my problem. I am having a simple java servlet program in my domino server. (regarding the set-up's for executing the servlet program in the domino server....all are through...no problem over there...every thing is done, as per the guidence in the domino administration help).
         I want to contact my above said servlet program (in my domino server), from my simple java program (in my client machine). To contact the servlet program from my client machine, i am using the cookie generated by the BROWSER (Internet Explorer), as the entry in to the domino server. But still the servlet program is not getting executed.
         As far As the servlet execution from the browser ("http://192.168.10.12:8001/servlet/testing"), the servlet program is getting executed. But If I get the same cookie (DomAuthSessID) from the browser, using the "alert(javascript:document.cookie)"......and try to call the servlet from my java program, the servlet is not getting executed....could u pl. advice me for the above problem.
    Thanks and Regards
    Subha
    Java program for ur reference:(client machine)
    import java.io.*;
    import java.net.*;
    public class authen
         public static void main(String args[]) throws Exception
         try
              HttpURLConnection urlconnection = null;
              URL serverURL = new URL("http://192.168.10.55:8001/servlet/testing");          
              urlconnection= (HttpURLConnection)serverURL.openConnection();
              urlconnection.setDoOutput(true);
              urlconnection.setRequestMethod("POST");
              urlconnection.setFollowRedirects(true);
              urlconnection.setRequestProperty("Connection", "Keep-Alive");
              urlconnection.setRequestProperty("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");
              urlconnection.setDoOutput(true);
              urlconnection.setDoInput(true);
              urlconnection.setUseCaches(false);
              urlconnection.setAllowUserInteraction(true);
              urlconnection.connect();
         catch (Exception e)
              e.printStackTrace();
    Hope, the way I have called my servlet program "testing" from my client machine is correct.
    SERVLET PROGRAM (Which resides in the domino server)
    import java.io.*;
    import java.text.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloWorldExample extends HttpServlet
    public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
    System.out.println("####");
    System.out.println("### DOMINO AUTHENTICATION ####");
    System.out.println("####");
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse) throws ServletException, IOException
    System.out.println("####");
    System.out.println("### DOMINO AUTHENTICATION ####");
    System.out.println("####");
    In the servlet.properties file, i have documented as,
    # HelloWorldExample properties
    servlet.testing.code=HelloWorldExample
    servlets.startup=testing

    Try to replace urlconnection.setRequestProperty
                ("DomAuthSessID","AAE228AB68335546B277E9B375412A8A");with urlconnection.setRequestProperty
                ("Cookie","DomAuthSessID=AAE228AB68335546B277E9B375412A8A");Let me know if this solves your problem
    BG

  • Calling Console Application that uses WebBrowser from SQL Server - Not Running

    Hi there. I am working in a program automation that needs to get files from a website and put it in a database. It is done but as I need a console application and need webbrowser that comes from Windows Forms, I am trying to call it from the SQL Server using
    the xp_cmdshell but when it runs the .exe, it execute the block that is before the Application.Run() command but when it reaches this line, it stay running on Task manager but it not execute my code. How can I fix this? I had first created a Windows form application
    but it was not working anyway and then I tried a console application and then I use the [STAThread] and Application.Run(). At least it runs the file from SQL Server but is not executing all my code, I think that it stops on Application.Run() line. Any help
    will be very useful.
    Thanks for now.

    Thanks for the response. What I mean is that it just run the part of the code that is just using the Console, that's the code:
    // Main Method
    [STAThread]
    public static void Main()
    clearDatabase(myConnection);
    Console.Title = "Suframa Itens Robot";
    //If log file exists, it is deleted
    if ( File.Exists(@"suframaLog.txt") )
    File.Delete(@"suframaLog.txt");
    wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(loginWebsite);
    try
    //It is called as the program uses the WebBrowser Class from Windows Forms namespace
    //and it is a console Application
    Application.Run();
    catch ( Exception ex )
    Log(ex.Message);
    As you can see, I call a function on start named ClearDatabase, when I call the file from sql server it executes, the tables are cleared, but what I think is that the problem stop when reach the line Application.Run() as it is the line that allows the remaining
    code to execute as it uses events from WebBrowser class. 
    It is a program automation that needs to get a lot of files from a website that needs login and read line by line from the files and put on server, if I call it from the executable it runs fine, the only problem is when calling from SQL Server, Do you know
    how to fix this?
    Thanks.

  • 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

  • How to call Servlet from jsp page and how to run this app using tomcat..?

    Hi ,
    I wanted to call servlet from jsp action i.e. on submit button of JSP call LoginServlet.Java file.
    Please tell me how to do this into jsp page..?
    Also i wanted to execute this application using tomcat.
    Please tell me how to do this...? what setting are required for this...? what will be url ..??
    Thanks.

    well....my problem is as follows:
    whenever i type...... http://localhost:8080/appName/
    i am getting 404 error.....it is not calling to login.jsp (default jsp)
    but when i type......http://localhost:8080/appName/login.do........it executes servlet properly.
    Basically this 'login.do' is form action (form action='/login.do').....and i wanted to execute this from login jsp only.(from submit button)
    In short can anyone please tell me how to diaplay jsp page using tomcat 5.5
    plz help me.

  • Calling a external Java method from JSP - using Tomcat server

    Hi all,
    I am trying to call a method in an external Java file from my JSP. I am using Tomcat server.
    I have my class within the package package "mypackage" and it is called myclass.class. It has only one static method mymethod() which reads from a file and writes to a file.
    I compiled the java class and I put the class file under webapps/ROOT/web-inf/classes/mypackage/myclass.class
    I am trying to say something like this from my JSP file(which is under webapps/ROOT) :
    <%@ page import = "mypackage.myclass"%>
    <% myclass.mymethod(); %>
    I am not instatiating the class as its a static method.
    This is what I get while accessing my jsp file :
    javax.servlet.ServletException: try to access class mypackage.myclass from class org.apache.jsp.index_005ftest_jsp
    To put my problem in a nutshell, Can someone guide me how to access a method of an external class from a JSP page? I have a bunch of pages doing the same operation so I thought I would have it in a method and call it from every page. Even though I tried to put the file under web-inf/classes, The JSP is not able to see the class.
    Please help.
    Thanks
    -Uday

    I have a situation that is a bit similar. I have successfully used beans for storing methods used in JSPs and used by other methods in the same class as was suggested above. Now I would like to break some methods into another (utility) class since they are lower level and can be used by lots of things. They are for database operations (given a String query and String dbname, it queries and returns ResultSet for example). I want to have them in a separate class for reusability and OOP.
    I am having problems calling those public static methods in the public class from my bean that communicates with the JSP. I can't compile the class that calls the method in the database ops class. I get an error like :
    loginHelper.java:45: cannot find symbol
    symbol : variable sqlHelper
    location: class dbHelperBean.loginHelper
    and when I include the package name in the call I get
    loginHelper.java:45: cannot find symbol
    symbol : class sqlHelper
    location: package dbHelperBean
    That's strange since the package of both classes is dbHelperBean and the class is indeed called sqlHelper. I tried to compile it in the same directory as sqlHelper as well. What am I doing wrong?
    Thanks for any help.

  • How to call jsp /servlets running in different web application in tomcat

    hello all,
    i have 2 web applications(Charts and Reports) in the same tomcat,i want to call jsp/servlets running in the Reports webapp from Charts webapp.how do i achieve this.
    thanx
    ravi

    You can also use getContext(String context) in the ServletContext class to get a request dispatcher.
    Using the above example it would be :
    // in a servlet in the charts webapp
    ServletContext context = getServletContext();
    ServletContext reportsContext = context.getContext("/reports");
    RequestDispatcher dispatcher = reportsContext.getRequestDispatcher("/path")
    dispatcher.forward(request, response);Just note, that depending on your server's configuration getContext(...) might return null.

  • Calling a class in JSP page using Tomcat 5.5

    Hi,
    I want to call a java class in a JSP page but getting error.
    I am trying to deploy JSP through a WAR file so for that I have created folder structure as per requirement and in WEB-INF folder, I kept web.xml file.
    What entry exactly I have to make in web.xml file as I am using Tomcat 5.5 webserver. When the same code I put in JSP then it works.
    my web.xml entry is
    <servlet>
    <servlet-name>TBS</servlet-name>
    <servlet-class>pack1.GetData</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TBS</servlet-name>
    <url-pattern>/JSP/TBS_main</url-pattern>
    </servlet-mapping>
    Do I need to change in it or we have to make some more entries in different XML files.
    Please help me to resolve this issue.
    Thanks
    Mukesh

    you dont have to specify the class file in the web.xml just import it on your jsp then instatiate the class on the scriplet and you can call the methods on it.

  • Native call in Servlet crashing tomcat

    I can execute the class from the unix prompt (invoking the main) and it works fine, however when I invoke it withing a servlet or jsp, i get a core dump.
    It seems to be a treading issue. I am including the tread dump of ONLY the thread that died.
    Any advice on getting this going would be appreciated.
    Derek
    SIGSEGV 11* segmentation violation
    si_signo [11]: SIGSEGV 11* segmentation violation
    si_errno [0]:
    si_code [2]: SEGV_ACCERR [addr: 0x0]
    stackpointer=ba12a2d4
    Full thread dump Classic VM (Caldera-UNIX-J2SE-1.3.0_02:*fixes-OU8*fixes-UW7*FCS-OSR5*:020322-03:47, native threads):
    "Thread-9" (TID:0xbca3aa50, sys_thread_t:0x83e7738, state:R, native ID:0xe) prio=5
    at JavaToCPageInterface.sendMessage(Native Method)
    at doit_3._jspService(doit_3.java, Compiled Code)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:119)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java)
    at org.apache.tomcat.facade.ServletHandler.doService(ServletHandler.java, Compiled Code)
    at org.apache.tomcat.core.Handler.invoke(Handler.java:322)
    at org.apache.tomcat.core.Handler.service(Handler.java, Compiled Code)
    at org.apache.tomcat.facade.ServletHandler.service(ServletHandler.java:485)
    at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java, Compiled Code)
    at org.apache.tomcat.core.ContextManager.service(ContextManager.java, Compiled Code)
    at org.apache.tomcat.modules.server.Http10Interceptor.processConnection(Http10Interceptor.java, Compiled Code)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java, Compiled Code)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java, Compiled Code)
    at java.lang.Thread.run(Thread.java:484)

    More Info:
    j2sdk 1.3.1
    Tomcat 3
    The program executes fine as a stand-along app, however if it is called from withing a servlet or JSP, Tomcat core dumps.
    Have tried -Xss10m as a parameter, however it does not work. I have also tried both green and native threads.
    Thanks,
    Derek

  • How to get data from the called program using SUBMIT in a background job?

    Hi Experts,
    I've a program which creates a background job using JOB_OPEN and JOB_CLOSE function modules.
    Between the above function modules I need to call a program using SUBMIT VIA JOB statement.
    My problem is, How do I fetch some data in an internal table in the called program to the calling program after the SUBMIT statement?
    I tried to EXPORT and IMPORT the data, but they are giving a failed sy-subrc when using this background job.
    Kindly let me know your inputs and valuable suggestions.

    Kumar,
    When we execute a program as a background job then the output will be sent to Spool which needs to be fetched again.I guess we need to use Submit via spool as mentioned by Rajat.
    Check these threads to get some idea
    submit report to spool & import spool id
    Re: Generate Spool for a report
    K.Kiran.

Maybe you are looking for

  • Exception in thread "main" java.lang.NoClassDefFoundError: oracle/xml/parser/v2/

    Hi! Kindly assist on the following error. I'm doing the sample acmevideo on Cashier Application deploying as a Java Application from JDeveloper3.0 and Oracle8i 8.1.5. And I had this error after executing the following command; Path=e:\javaWebServer2.

  • Apple's Free Custom Ringtones

    I haven't seen this mentioned today in this forum but Apple quietly upgraded Garageband to allow the making of custom iPhone ringtones. It is now very easy to do and Garageband sports an icon for importing your custom ringtone (taken from just about

  • Windows on a mac i not working

    Hi, I got a new iMac the other day and I went to installwindows using boot camp. Boot camp worked and all, but when I went to installgames and other software's I get this message that tells me that "windows cantuse the graphics that are installed bec

  • DDL Wait option and ddl_lock_timeout in oracle 11G

    SQL> select * from v$version; BANNER Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production PL/SQL Release 11.1.0.6.0 - Production CORE 11.1.0.6.0 Production TNS for Solaris: Version 11.1.0.6.0 - Production NLSRTL Version 11.1.0

  • RoboHelp 7.0.3 looking for CWDLL32.dll?

    When I run RoboHELP 7.0.3 I get a dialog box stating, "This application has failed to start because CWDLL32.dll was not found. Re-installing the application may fix this problem." I completely uninstalled and reinstalled the app, same thing. Any idea