How do i run a servlet??????

running servlets:i downloaded jsdk but how do i run a servlet? i got the error
C:\WINDOWS\Desktop>javac HTTPGetServlet.java
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/M
ain
when i tried to run my servlet, please help
thanks

As mentioned in another post in the thread, servlets run from within a web server that has pre-loaded the jvm and serves web requests. Often they are called 'sevlet containers' as they act like a wrapper program for the actual vm. Tomcat is such a web server, quite a popular one for running servlets, and is considered the reference implementation for a sevlet/jsp server. you can read up on it at...
http://jakarta.apache.org/tomcat/index.html
To get you started, this is what i did to set up tomcat. Im using RedHat Linux at home, so this may differ to what you have to do initially.
First, make sure you have at least the jsdk and jsdk ee installed and the appropiate JAVA_HOME and J2EE_HOME environment variables set.
I am using the Apache web server to handle web page requests on my box. If the request is for a context containing a servlet or jsp file (context is a tomcat term for a particular location or path in the url) then apache passes the request to tomcat via a apache module and a special protocol. Tomcat then runs the .class file or .jsp file, returns the output to apache which then returns the output back to the browser. So initially you should set up and have the apache web server running.
Next download and install the jserv or tomcat module for apache, which apache uses to communicate with tomcat via a special protocol, and the tomcat rpms from...
http://jakarta.apache.org/builds/jakarta-tomcat/release/v3.2.3/rpms/
...Im using 3.2.3 which works fine. you may try the later versions if you like.
Install the tomcat rpms. They should dump a whole lot of stuff in a /var/tomcat directry, including some nice sample and admin apps. if you had downloaded and installed the tomcat-manuals rpm you can find lots of helpful information in the /usr/doc/tomcat-{your version here}/ directry. This is what you should probably read through now!
Once that is done, its simply a matter of adding a reference in your httpd.conf file to the tomcat.conf file in the tomcat/conf dir (if you want to have complete control over the tomcat module and contexts) or tomcat-apache.conf (in the same directry) if youd like tomcat to handel its own configuration of apache. something like...
include /var/tomcat/conf/tomcat.conf
...should do.
then run tomcat start (in /usr/bin/) and apache and away you go. You should be able to point your browser to your.server.com/admin/ and get the tomcat admin tools. This allows you to add view and delete contexts to your server (say for separating different server-side applications). your.server.com/examples/ has some nice stuff as well.
Hope this helps. I warn you im not an expert and haven't looked at this stuff for some time. I probably have something wrong so please, experts, if you see something stuffed up let us know.

Similar Messages

  • How can I run a servlet with Sun Java System Application Server PE 8?

    I've created a package with a TestServlet.class inside, used the deploytool to create a WAR and deployed this using the autodeploy folder.
    The filestructure has been generated and I find the TestServlet.class in
    [installdir]\domains\domain1\applications\j2ee-modules\testProject\WEB-INF\classes\[packagefolderstructure]\TestServlet.class.
    The context root is working fine, but I have no clue how I can run the servlet directly via the URL.
    I've tried many things like
    http://localhost:8080/testProject/TestServlet
    http://localhost:8080/testProject/servlet/TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithpoints]TestServlet
    http://localhost:8080/testProject/servlet/[packagenamewithslashes]TestServlet
    etc etc
    Can somebody tell me please how to write URLs to deployed servlets? Or send me an example url and xml descriptor files?
    Thanks a lot in advance!

    in web.xml use servlet mapping
    <servlet-mapping>
        <servlet-name>TestServlet</servlet-name>
        <url-pattern>/doit</url-pattern>
    </servlet-mapping>then use http://localhost:8080/testProject/doit

  • How do we run a servlet program in eclipse

    how do we run a servlet program in eclipse.

    Not at all, because servlets require a servlet container. Some Eclipse plugins (Lomboz etc.) do provide integration with those.

  • How do you run a servlet with no effect on the browser window?

    Is it possible to send parameters to a servlet (using POST or, if necessary, GET) from an application or html page running in a browser, without causing the current browser to be redirected, and without opening a visible new browser window to run the servlet?
    If so, can you explain how to do this?

    Sure, you could embed it as an image tag.
    <img src="http://yourserver/servlets/MyServlet?param1=foo&param2=bar" height=1 width=1>
    This will probably produce a broken image in some browsers, unless you have your Servlet send a 1x1 pixel image to its output stream.
    -Derek

  • How can I run a servlet with tomcat

    I'm a new learner in servlet,I recently write a servlet program,when I compile it,the compiler throws the error
    "package javax.servlet.http does not exist",I have put the servlet.jar(which exist in d:\tomcat\bin directory) file into the classpath directory;my servlet source files are in D:\tomcat\webapps\mywork\web-inf\classes\com\stardeveloper\servlets;
    "com.stardeveloper.servlets" is the package for my servlet source files,so I have write the sentence "package com.stardeveloper.servlets;" in my servlet source file.
    I don't know how to resolve this problem.can you give me a help?

    servlet.jar doesn't exist in the folder you mentioned, but rather, in C:\tomcat40\common\lib, so this should be included in your classpath, the other thing you should care about is how you compiled your servlets, so that the package statement match the hirarchy of the file.
    regards

  • How can i run first servlet satish

    when i am running servlet it's giving 505 error what is that

    ok satish i will give u solution about this
    505 is server does't understand where is u r file ie servlet file

  • How to run a servlet in tomcat

    how i can run a servlet in tomcat?

    how i can run a servlet in tomcat?Don't try to do that yet; in your other thread you have shown that your are
    not capable yet of setting up a proper development environment.
    Take my advice, you can't walk or run yet so start with the basics.
    kind regards,
    Jos

  • How can I test a Servlet?

    Hello!
    I want to test a small part of a servlet. That part connects to a database through a DataSource which is obtained in this manner:
    Context ctx = new InitialContext();
    ds = (DataSource) ctx.lookup(dsLookup);
    conn = ds.getConnection();Details about the servlet: runs on a WebSphere application server with db2 database. Runs on the local server in our intranet and I create a Java project in Eclipse with Create project from existing source: path to location on server.
    It's really annoying to start the browser, get to the page I'm interested, make the neccesary request and then see what happens in my code.
    What I've learned so far:
    I can't test it in a main function because I can't get the context. I tried setting the context's properties, still no go.
    I found this: http://www.ibm.com/developerworks/rational/library/08/0219_jadhav/
    but I got lost when it came to adding the resource reference to the project. How can one do that in Eclipse?
    Can anyone please, please, pretty please with sugar on top, explain to me how I can do this?
    Thank you very much for your time,
    Iulia

    Thank you for your prompt reply. I still have some questions:
    You say that configuration must go in the web.xml file. I don't have that file. In the tutorial example one application is a Java project the other is an application client and the other is an EAR of the application client. Neither of them have a web.xml file. So where do I set the resource?
    Do I have to have a WebSphere application server installed on my local machine?Where and how do I run the servlet?
    Thank you,
    Iulia

  • Problems compiling and running a servlet

    I have been trying to compile and run my servlet program to no avail. Please help. I am using Tomcat 5.5 and j2sdk1.4.2
    These are the errors I keep getting. I have already set the classpath appropriately.
    MyServletTest.java:5: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    MyServletTest.java:6: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    MyServletTest.java:10: cannot resolve symbol
    symbol : class HttpServlet
    location: class MyServletTest
    public class MyServletTest extends HttpServlet {
    ^
    MyServletTest.java:13: cannot resolve symbol
    symbol : class HttpServletRquest
    location: class MyServletTest
    public void doGet (HttpServletRquest req, HttpServletResponse resp)
    ^
    MyServletTest.java:13: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class MyServletTest
    public void doGet (HttpServletRquest req, HttpServletResponse resp)
    ^
    MyServletTest.java:48: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class MyServletTest
    private void printResultSet (HttpServletResponse resp, ResultSet rs)
    throws SQLException {
    ^
    MyServletTest.java:52: cannot resolve symbol
    symbol : method prinln (java.lang.String)
    location: class java.io.PrintWriter
    out.prinln("<html>");
    ^
    7 errors

    Thank you. I have managed to compile the program but
    when I run it I get:
    Exception in thread "main"
    java.lang.NoSuchMethodError: main
    How should I run a servlet?Servlets are not run like applications. You need to deploy them to a servlet container, and they get invoked and initialized by constructor, init() method and goGet/doPost().

  • How to run a servlet in tomcat 5.0.

    Hi all,
    how to run a servlet in tomcat 5.0
    please tell me the entire procedure....(directory structure)
    step by step....

    hi :-)
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets.html
    or
    http://www.google.com.ph/search?hl=en&q=java+servlet+tutorial&btnG=Google+Search&meta=
    regards,

  • How to Compile/Run servlet in Tomcat 4.1

    Hi All,
    iam trying to compile my servlet program in tomcat4.1.. but its showing an error
    in the import statement..
    UN SOLVABLE SYMBOL... but the import ststement is correct...
    can any one help ... is there i have to set any path for compiling/running the servlet...
    Thanks in Advice

    hi thanks for your reply
    i have loaded tomcat4.1 exe -- for windows i am starting the tomcat server by clicking from the start menu..
    i dint set any env variable .. tell me how to set...
    regards
    ijay

  • How Can I Run Servlet in tomcat

    Hi My Friends
    Please can any one tell me how can I Run Servlet in tomcat using my own Virtual Directory � my ask about , what is the structure it must be make it in the hierarchy of the sub folder of Virtual Directory , and in watch folder it must be put the servlet files and there is any change it must be make it in any file of the tomcat files and so on
    Please give my full details about this thing
    And thanks

    What version of Tomcat are u using?

  • How to run a servlet in vqserver????

    any one know how to run a servlet using vqserver..pleazzzzzzzzzz..

    Why not read the doc at vqserver.com??
    But its' really simple:
    copy classes into vq/servlet directory
    open http://localhost:9090
    create an alias to your servlet
    and test

  • How to run a servlet in Tomcat 5.0 server

    HI Everybody,
    I want to know how to run the servlet file on my tomcat 5.0 server. that is where to place a class file and deployment details.
    Thanks In ADVANCE

    Sourav_cs wrote:
    I am a biginner to start servlet i get confusion to configure servlet in tomcat 5 where it should be saved in tomcat directory and how to execute that as first timeHi,
    goto
    tomcat 5.0\webappsnow create a folder here. this is your webapplication project name. Let's suppose it as "TestApp"
    inside this create directories as follows :
    TestApp
            |
            |-----JSP/htmls( if you have any )
            |
            |-----WEB-INF(File Folder)
                       |
                       |-----web.xml
                       |-----lib ( Directory. place all the .jar files which are required for this project(if any) )
                       |-----classes ( .class files. )[all of your java code should be placed here.](servlets / beans/ pojo )this is the general Directory structure of a web application. now you've to place the compiled .class file of your servlet in the "TestApp\WEB-INF\classes" directory. make sure that you've configured the servlet in Deploment Desctiptor, i.e, web.xml.
    now start the server and type the url like : "http://localhost:8080/TestApp/TestServlet"
    the port no. 8080 is the default port no. of tomcat. you have to give your port no. if u've modified it. and TestServlet is the <url-pattern> of your servlet.
    go through some tutorials .. then you can easily know that
    Diablo

  • How I can run servlets in Apache 1.3.2.7

    hi i am using JSP as Interface..and Servlets as controller...
    also Using Apache Httpd server,verion is 1.3.2.7
    plz tell me how i can use apache to run my servlets.
    Rahul.

    To run servlets in Apache you need the mod_jk module. But as the previous post, it is better to use Tomcat and putting both, Apache and Tomcat, working together. Tomcat will serve all the java related things, and the Apache, the html, php, etc.

Maybe you are looking for

  • How does the TS_SeqFileSequenceNameExists() function work?

    I am creating a TestStand Sequence file using CVI and would like to know the correct syntax for using the TS_SeqFileSequenceNameExists() function. Basically what I'm trying to do is add a sub sequence to my file and if the sequence name already exist

  • Related files of html-file in top panel

    Earlier, when I used DW there was a sequence of related files of html-file: it's css, js -files. How can I switch on it's displaing? Much thanks!

  • Calling oracle procedure from ABAP program

    There is a requirement to call the oracle stored procedure with some input parameter from ABAP program. Suppose we have order number which is entered by the user in ABAP program. This order number needs to be passed to oracle stored procedure as an i

  • Total Compensation Statement Configuration (ESS)

    Hello, does anyone know where do I have to go in ERP 2004 to configure "Total Compensation Statement"? I've created a new form in Smart Forms and now I want to change the default form used in the Portal. Thanks a lot Antonio

  • Stacked bar chart - layout

    Hi, is there any way to control the layout of a stacked bar chart (bar width and (horizontally) distance between bars)? In my chart all bars are on the left side while there is much free space on the right side. So is there a possibility to dynamical