Servlet program in eclipse

hi all,
i write simple hello servlet program in eclipse...
but compiler tells " javax.servle.* " cannot be resolved...
plz clarify how to run servlet program in eclipse as a tomcat webserver....
import java.io.*;
import javax.servlet.*;
public class helloservlet extends GenericServlet{
     public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException
     response.setContextType("text/html");
     PrintWriter pw= response.getWriter();
     pw.println("hello servlet");
     pw.close();
}regards
machepalli

hi,
if you are using tomcat 5.5 server use jdk1.5 and if you use tomcat 5.0 use jdk1.4 then compatability adjust.And jar files to library go to tomcat-home ->common->lib->Servelet-api.jar file to your java program library.....
And better to use myeclipse1.4 instead of eclipse ... bcoz sometimes it requires plugins to avoid that use myelipse1.4 ......

Similar Messages

  • 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 to run servlet program in eclipse 3.1

    i run the jsp program in eclipse 3.1
    i want to run sample servlet program in eclipse, how to create the project,where to store the class file..? where to store the web.xml file..?
    plz give explanation with HelloWorld.java program....

    Install WTP and follow the basic J2EE WebApp Tutorial from their WTP tutorials page.

  • 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.

  • Error while running a Servlet program in Eclipse IDE

    Hi,
    I have tried running the following program in the Eclipse Editor. It doesnt compile. I have installed the Tomcat plugin too.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class HTTPGetServlet extends HttpServlet {
         public void doGet(HttpServletRequest request,
                   HttpServletResponse response)
         throws ServletException, IOException
              PrintWriter output;
              response.setContentTe("text/html");
              output=response.getWriter();
              StringBufer buf=new StringBuffer();
              buf.append("<HTML><HEAD><TITLE>\n");
              buf.append("A simple servlet example\n");
              buf.append("</TITLE></HEAD><BODY>");
              buf.append("<H1>Welcome to the world</H1>\n");
              buf.append("</BODY></HTML>");
              out.println(buf.toString());
              output.close();
    On a closer look i realized that the IDE is showing as error any import statements i type in. Can anyone help me get over this problem? Thanks a lot in advance.
    bye
    V

    You need to add the JAR containing the servlet API in the external JARs for the project.
    Regards,
    Carol.

  • How to execute jsp.servlet program in eclipse with small example

    This is sasidhar,
       How to set classpath pf tomcat to eclipse.
    and how to run jsp and servlets in eclipse 3.o
    thanks&regards
    sasidhar

    HI,
    Try these links
    http://help.sap.com/saphelp_nw04/helpdata/en/64/620a2ae361344abf47462809eb5388/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/f6/baba3eb645dc61e10000000a114084/frameset.htm

  • Weblogic error while deplying a simple servlet program

    Hi This is a very simple servlet program.
    I am trying to deploy it on the weblogic server but i get this error as follow
    Unable to access the selected application.
    *javax.enterprise.deploy.spi.exceptions.InvalidModuleException: [J2EE Deployment SPI:260105]Failed to create*
    DDBeanRoot for application, 'E:\AqanTech\WebApp1\myApp.war'.
    I have checked everything, right from my code to my web.xml file. I have used a build.bat file to build my war file.
    PLEASE HELP ME TO SOLVE THIS HUGE PROBLEM OF MINE ?
    Thanks,
    Shoeb

    Hi,
    The J2EE Error code siply suggest that there is something wrong in your Deployment Descriptors...
    Can u please post the XML files available inside your "WEB-INF" directory?
    Thanks
    Jay SenSharma
    http://jaysensharma.wordpress.com (WebLogic Wonders Are Here)

  • Inputting an excel file to the java servlet program

    Hi,
    How can I input an excel file into the java servlet program? I am using POI HSSF programming to read the content of that excel file.I have created a form that will accept the path from the user and in the servlet program, I have called a post method to retrieve the path of the file. I am getting the path of the file as a string.Then I have to access the file to read the data. But it is not working. What should I do?.Please help me.
    I have created an html file to create a form that will ask the path of the file to be loaded into the servlet program.Please give me a solution,thanks in advance. The servlet program that receives the file is shown below. It just only take the name of the file and prints if that is ok.
    <html>
    <body bgcolor="green">
    <center>
    <form method="post"  action="http://localhost:8080/examples/servlet/Ron1">
    <table>
    <tr>
    <td><B>ENTER THE PATH OF THE FILE</td>
    <td><input type=file name="path"></td>
    </tr>
    </table>
    <input type=submit value= "submit" >
    </form>
    </body>
    </html>
    import java.io.*;
    import javax.servlet.*;
    import java.lang.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import java.text.*;
    import java.util.*;
    import com.oreilly.servlet.MultipartRequest;
    import org.apache.poi.hssf.usermodel.*;
    public class Ron1 extends HttpServlet
       public void doPost(HttpServletRequest request, HttpServletResponse response)   throws IOException, ServletException
            response.setContentType("text/html");
            PrintWriter out = response.getWriter();
            String u = request.getParameter("FileToUpload");
            out.println("The Path is "+u);
            System.out.println("The path is "+u);
            MultipartRequest multi = new MultipartRequest(request,u,10 * 1024 * 1024);
            System.out.println("path is "+u);
            Enumeration files = multi.getFileNames();
            File fUploadedFile = null;
            String sFileName = "";
            out.println("path is "+u);
            while(files.hasMoreElements())
                            String name = (String)files.nextElement();
                            out.println("file is "+name);
                            sFileName = multi.getFilesystemName(name);
                            String type = multi.getContentType(name);
                            fUploadedFile = multi.getFile(name);
                    FileInputStream fis= new FileInputStream(fUploadedFile);
                   HSSFWorkbook wb=new HSSFWorkbook(fis);
                    System.out.println("The path is "+u);
                    out.println("File has identified successfully\n");
                    out.close();
       }

    Hi,
    Can you try to use classes from java.net package (URL, URLConnection) to pass the contents of excel file to servlet?
    HTH
    Vishal

  • Error while running jms program in eclipse

    Hi,
    Friends.I am new to forum.This is the first question I am posting.I am new to Java Messaging service.While running the program in eclipse I am getting the following error...
    javax.jms.JMSException: MQJMS2005: failed to create MQQueueManager for 'scsstasdap03:QSEIBEL'
         at com.ibm.mq.jms.services.ConfigEnvironment.newException(ConfigEnvironment.java:569)
         at com.ibm.mq.jms.MQConnection.createQM(MQConnection.java:2328)
         at com.ibm.mq.jms.MQConnection.createQMNonXA(MQConnection.java:1749)
         at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:144)
         at com.ibm.mq.jms.MQQueueConnection.<init>(MQQueueConnection.java:54)
         at com.ibm.mq.jms.MQQueueConnectionFactory.createQueueConnection(MQQueueConnectionFactory.java:106)
         at com.bofa.pbes.cedapi.cmwmq.JMSManager.<init>(JMSManager.java:87)
         at com.bofa.pbes.cedapi.cmwmq.JMSManager.<clinit>(JMSManager.java:40)
         at com.bofa.pbes.cedapi.cmwmq.JMSCEDAgent.<init>(JMSCEDAgent.java:24)
         at com.bofa.pbes.cedapi.cmwmq.MessageProcessingController.<init>(MessageProcessingController.java:34)
         at com.bofa.pbes.cedapi.cmwmq.MessageProcessingController.<clinit>(MessageProcessingController.java:38)
    java.lang.ExceptionInInitializerError
    Caused by: java.lang.NullPointerException
         at com.bofa.pbes.cedapi.cmwmq.JMSManager.addMessageListener(JMSManager.java:173)
         at com.bofa.pbes.cedapi.cmwmq.JMSCEDAgent.<init>(JMSCEDAgent.java:25)
         at com.bofa.pbes.cedapi.cmwmq.MessageProcessingController.<init>(MessageProcessingController.java:34)
         at com.bofa.pbes.cedapi.cmwmq.MessageProcessingController.<clinit>(MessageProcessingController.java:38)
    Exception in thread "main"
    Please help me.....

    Have a look in eclipse in the menu under window -> preferences -> java -> installed jre's which one is selected there.
    Than you have to check you project settings: right click on the project and select properterties. Check "Java Build Path" and "Java Compiler" settings.
    If you run your program, the console also shows the version you are running. If it is an 1.6 version everything should work.

  • How to run the simple java card program in eclipse?

    I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
    Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • Problem in compiling aa servlet program

    I have installed jsdk1.4.2_13
    And also installed tomcat 5.0.28
    I have set
    CATALINA_HOME==C:\Program Files\Tomcat\jakarta-tomcat-5.0.28
    JAVA_HOME ==C:\j2sdk1.4.2_13
    CLASS_PATH==
    C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar;
    C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\jsp-api.jar
    PATH ==C:\j2sdk1.4.2_13\bin;C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\bin;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem
    -->My java programs are compiling
    -->I can run tomcat server , And also can see starting page of "http://localhost:8080/"
    But I am not able to compile servlet program
    MY sevlet program is
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class HelloServlet extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1>Hello</H1>\n" +
    "</BODY></HTML>");
    ERRORS are:
    Pakage javax.servlet does not exist
    Pakage javax.servlet.http does not exist
    cannot resolve symbol HttpServletRequest
    and similar errors
    can anyone guide me?
    Message was edited by:
    Learn

    it's not CLASS_PATH, it's CLASSPATH.
    Directory paths with spaces in them are problematic. Surround them with double quotes.
    I think the best thing is not a CLASSPATH environment variable. Better to use the -classpath option on javac.exe when you compile.
    So your command to compile might look something like:
    javac -classpath .;"C:\Program Files\Tomcat\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar" *.java%

  • How i run this program in eclipse 3.2

    i have no idea to run program in eclipse.. how can i run this....
    public class AreaOfCircle {
         double radius = 0.0;
         double area = 0.0;
         public AreaOfCircle(double rds) {
              radius = rds;
         public void getArea() {
              area = 3.14 * radius * radius;
              System.out.println("Area Of Circle Is : " + area);
         public static void main() {
              AreaOfCircle obj = new AreaOfCircle(5.3d);
              obj.getArea();
    }

    [First hit looks promising...|http://www.google.com/search?hl=en&q=eclipse+java+tutorial&btnG=Google+Search]

  • 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 ?

  • Help ~~ Cannot compile servlet program

    I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
    package javax.servlet does not exist
    I've download the class files and set the classpath already. Have I missed anything?
    Thx!

    I have recently written a servlet program. When I
    compile the program (let's say "HelloWorld.java"),
    I've got the following error message:
    package javax.servlet does not existyou donot have servlet api classes in your classpath
    I've download the class files and set the classpath
    already. Have I missed anything?just check the classpath again and compile.
    say echo CLASSPATH and see

  • Cannot compile servlet program

    I have recently written a servlet program. When I compile the program (let's say "HelloWorld.java"), I've got the following error message:
    package javax.servlet does not exist
    I've download the class files and set the classpath already. Have I missed anything?
    Thx! ^-^

    Maybe you should listen in at
    http://forum.java.sun.com/thread.jsp?forum=45&thread=234654
    He has a similar problem.
    Did you put the servlet.jar in your classpath?

Maybe you are looking for