Problem in compiling servlets

Hi
I have j2sdk1.4.0 and i am using J2ee application server.My problem is while compiling i get error as "javax.servlet" package not found.Can anybody suggest me how to give the classpath for successful compilation.
regrds
Vaijayanthi

hi vaiju
basically it gets struck while finding as well loading the appropriate library files when there is a request for servlet.. tats where it gave the error of javax.servlet is missing..
all servlet and jsp related files (class files) reside in this javax.servlet package.. its there javax.servlet jar or simply servlet.jar or even you can use the j2ee.jar which the superset of all of these..
you can any one of the following 2 things:
(1) you can either set the classpath of your pc to point to or include the location where it contains any of these .jar files
(2) you can put the reqd lib files in the container's (web/app server's) location which it internally maintains for searching while loading/running the applications...
here you have two options
(a) either you can include the jar files with the individual applications (your applications WEB-INF/lib folder, which you can find inside the <TOMCAT_HOME>/webapps/ YOUR_APP_ROOT/WEB-INF/lib folder)
(b) you can put the jar files in the common place of the container in case of being required by several applications (in case of tomcat, you can put in <TOMCAT_HOME>/common/lib folder).
Dont forget to mention this in the build.xml file in case if you use ANT tool to build your application. you can set the <property> for the classpath.
Hope this helps...
Good luck to your journey in Servlets....

Similar Messages

  • Problem in compiling servlet

    hi
    i'm trying to compile a simple servlet
    my directory structure is as follows
    c:\pr1
    |
    |____src
    |
    |______chservlet.java
    |
    |____classes
    |
    |____etc
    |
    |______web.xml
    c:\Tomcat5.0
    |
    |____webapps
    |
    |______ch1
    |
    |____WEB-INF
    |
    |____classes
    and the list of variables is as follows
    TOMCAT_HOME=c:\Tomcat 5.0\bin
    JAVA_HOME=c:\jsdk1.4
    classpath = %CLASSPATH%;c:\Tomcat 5.0\common\lib\servlet-api.jar
    now when i'm trying to compile the servlet by giving the following command
    javac -classpath ".;c:\Tomcat5.0\common\lib\servlet-api.ajr" -d classes c:\pr1\src\chservlet.java
    i'm getting the error package..
    javax.servlet.* doesnt exist
    can anybody help me at the earliest
    Regards
    jaismeen

    sorry guys..for starting each time new thread..just registered myself to the site yesterday after facing this problem..so cudnt get familiar with its working..
    i have given the commands as follows..
    set classpath=c:\Tomcat5.0\common\lib\servlet-api.jar,%classpath%
    set path=c:\jsdk1.4\bin;%path%
    javac c:\pr1\src\chservlet.java
    getting the following errors
    C:\>javac c:\pr1\src\chservlet.java
    c:\pr1\src\chservlet.java:1: package javax.servlet does not exist
    import javax.servlet.*;
    ^
    c:\pr1\src\chservlet.java:2: package javax.servlet.http does not exist
    import javax.servlet.http.*;
    ^
    c:\pr1\src\chservlet.java:5: cannot resolve symbol
    symbol : class HttpServlet
    location: class chservlet
    public class chservlet extends HttpServlet
    ^
    c:\pr1\src\chservlet.java:7: cannot resolve symbol
    symbol : class HttpServletRequest
    location: class chservlet
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOExcep
    tion
    ^
    c:\pr1\src\chservlet.java:7: cannot resolve symbol
    symbol : class HttpServletResponse
    location: class chservlet
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOExcep
    tion
    ^
    5 errors
    was just wondering.ihave windows xp..so does it effect in anyway(it shud not)
    and if name of the servlet is given wrong then it shudnt give these set of errors..it shud give kind a"cudnt find the file name"
    and i have checked the classpath..servlet-api.jar is present and is in this location
    c:\Tomcat 5.0\common\lib
    and i had tried giving the command
    jar -tvf servlet-api.jar..
    it gives the list of classes..which shows..its present in the directory
    jdk is present in c:\jsdk1.4
    location of servlet is c:\pr1\src\chservlet.java
    servlet code is as follows
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class chservlet extends HttpServlet
    public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException
    PrintWriter out =res.getWriter();
    java.util.Date today= new java.util.Date();
    out.println("<html>"+
    "<body>"+
    "<h1 align=center>HF\'s Chapter1 Servlet<h1>"
    +"<br>"+today+"</body>"+"</html>");
    even i tried copynig servlet-api.jar in the same directory as the servlet and compiling it..
    it gives the same set of errors
    am just wondering what cud be the problem.sure..must b very smal..but i m not progressing much
    regards

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

  • Problem while compiling Servlet

    M using Tomcat.
    Environment variables :
    Variable :::::::::::::::: Values
    %TOMCAT_HOME% ::::::::::: C:\Tomcat\bin
    CLASSPATH :::::::::::::::: .;C:\jdk 1.4.2\lib;C:\jsdk2.1 \servlet.jar;C:\Tomcat\lib\servlet.jar;
    PATH ::::::::::::::::::::: ;C:\jdk 1.4.2\bin
    JAVA_HOME :::::::::::::::: C:\jdk 1.4.2
    Now problem is that When m trying to compile GreetingServlet.java
    problems are:::
    GreetingServlet.java:31: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("<BODY>");
    ^
    GreetingServlet.java:32: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("<p>"+message +","+name+"</p>");
    ^
    GreetingServlet.java:33: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("<p> Thanks ("+email+")</p>");
    ^
    GreetingServlet.java:34: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("<p> -The Pro Java Team.</p>");
    ^
    GreetingServlet.java:35: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("</BODY>");
    ^
    GreetingServlet.java:36: cannot resolve symbol
    symbol : method Println (java.lang.String)
    location: class java.io.PrintWriter
    out .Println("</HTML>");
    ^
    Source Code:
    import javax.servlet.* ;
    import javax.servlet.http.* ;
    import java.io.* ;
    import java.util.* ;
    public class GreetingServlet extends HttpServlet{
    protected void doPost (HttpServletRequest request,
                   HttpServletResponse response)
                        throws ServletException, IOException {
         String name = request.getParameter ("name");
         String email = request.getParameter ("email");
         String message = null;
         GregorianCalendar calendar = new GregorianCalendar();
         if (calendar.get(Calendar.AM_PM) == Calendar.AM) {
              message =" Good Morning";
         else {
              message = " Good Afternoon";
         response.setContentType("text/html");
         PrintWriter out = response.getWriter();
         out .println("<HTML>");
         out .Println("<BODY>");
         out .Println("<p>"+message +","+name+"</p>");
         out .Println("<p> Thanks ("+email+")</p>");
         out .Println("<p> -The Pro Java Team.</p>");
         out .Println("</BODY>");
         out .Println("</HTML>");
         out .close();
    Thanks in Advance
    Please its an urjent.
    Hoping to get the solution soon from cream like you in Programming.

    hi
    it could be you have caps P.
    try:
    "println" instead of "Println".

  • Problem regarding compiling servlet

    Can any body pl help me
    I have installed tomcat 4.0 And suceesfully compiled all the jar file in <catalina Home>/Apache Tomcat 4.0/Common/lib including servlet.jar , when i want to compile i am getting httpservlet error like this.
    examp.java:6: cannot resolve symbol
    symbol : class HttpServlet
    location: class examp
    public class examp extends HttpServlet {
    ^
    Pl help me in this regard
    Thanking you
    anantha

    I am very new to Servlet..
    I have installed tomcat 4.0 And suceesfully compiled all the jar file in <catalina Home>/Apache Tomcat 4.0/Common/lib including servlet.jar
    I am getting " examp.java:1: package javax.servlet does not exist
    import javax.servlet.*;" .Please tell me how to solve this pbm
    Thanks
    anantha

  • Compiling Servlet problem that uses a JavaBean

    I have a servlet that will get data from a JavaBean which is created before in a jsp file. While I trying to compile the servlet I am getting this message:
    --------------------Configuration: JDK version 1.3 <Default>--------------------
    Command : "C:\jdk1.3\bin\javac.exe" -d "C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes" C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java
    Directory : C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\TasitKayitGirisi.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean = (SimpleBean) session.getAttribute
    ^
    ("simpleBean");
    C:\jakarta-tomcat-3.2.1\webapps\ROOT\WEB-INF\classes\MyServlet.java:19: cannot resolve symbol
    symbol : class SimpleBean
    location: class MyPackage.SimpleBean
         SimpleBean simpleBean= (SimpleBean) session.getAttribute("simpleBean");
    ^
    2 errors
    Process completed.
    Where is the problem. SimpleBean is successfully being initializing in my jsp file. But I couldn't compile my servlet that will get data from that bean. Both my servlet and bean are in the same package. I am using JCreator to compile servlets. I think the problem is the compile string that JCreator uses. Can you help me. Thx in advance.

    Hi,
    The problem is it is not finding the Bean. Put it in the classpath.
    The simplest way is put the class in /WEB-INF/classes/MyPackage folder.

  • Problems to compile a servlet

    Hi, i have a problem to compile a servlet, i will try to explain my problem easily...
    i have a JavaBena class int he directory.....C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes......and i have compiled it by DOS commands, everyhting has gone well!
    i have a Servlet class in the same directory where it situated the JavaBean. i compile the Servlet as well as i have done with the Javabean, by DOS commans, including the Tomcat servlet api.
    this is the command which i use to compile the servlet.......javac ServletRegistraUtente.java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar".....
    but everything i get this error...
    C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>javac ServletRicercaUtente
    .java -classpath "C:\Programmi\Apache Software Foundation\Tomcat 6.0\lib\servlet-api.jar"
    ServletRicercaUtente.java:20: cannot find symbol
    symbol : class BeanRicercaUtente
    location: class ServletRicercaUtente
    ^
    ServletRicercaUtente.java:20: cannot find symbol
    symbol : class BeanRicercaUtente
    location: class ServletRicercaUtente
    BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
    ^
    2 errors
    C:\Programmi\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes>
    these are the 2 classes....
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import JavaBean.BeanRicercaUtente;
    public class ServletRicercaUtente extends HttpServlet
         public void doPost(HttpServletRequest request, HttpServletResponse response)
         throws IOException, ServletException
              ServletContext sc;
              RequestDispatcher rd;
              try
                   BeanRicercaUtente m_BeanRicercaUtente = new BeanRicercaUtente();
                   request.setAttribute("m_BeanRicercaUtente", m_BeanRicercaUtente);
                   String codiceFiscale = request.getParameter("codice");
                   m_BeanRicercaUtente.effettuaRicerca(codiceFiscale);
                   sc = getServletContext();
                   rd = sc.getRequestDispatcher("/risposta.jsp");
                   rd.forward(request, response);
              catch(Throwable theException){}
    import java.sql.*;
    public class BeanRicercaUtente
         String nome, cognome, indirizzo, telefono;
         public void effettuaRicerca(String codiceFiscale)
              try
                   Class.forName("com.mysql.jdbc.Driver");
                   String url = "jdbc:mysql://.................";
                   Connection con = DriverManager.getConnection(url);
                   Statement cmd = con.createStatement();
                   String qry = "SELECT ..................";
                   ResultSet res = cmd.executeQuery(qry);
                   while (res.next())
                        cognome = res.getString(1);
                        nome = res.getString(2);
                        indirizzo = res.getString(3);
                        telefono = res.getString(4);
                   res.close();
                   cmd.close();
                   con.close();
              catch (SQLException e)
                   e.printStackTrace();
              catch (ClassNotFoundException e)
                   e.printStackTrace();
    i would be glad to get help about it...! :) thanks!

    i am sorry, but in the first class i have not written "import JavaBean.BeanRicercaUtente;"
    i have only these imports...
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;

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

  • Compiling servlet with helper class

    Hello,
    I have to write a very large number of database queries and huge amount of code so I decided to make each helper *.class file for each table.
    Now I have a main servlet that should instantiate each of these helper classes and conduct DB operations:
    //Servlet code
    RescardreservationTable rv = new RescardreservationTable();
    rv.insertInfo();
    RescardPassengerTable rp = new RescardPassengerTable();
    rp.insertInfo();RescardreservationTable.class
    //does DB opsMy problem is that when I try to compile servlet, I get
    insert_data.java:172: cannot find symbol
    symbol : class RescardreservationTable
    location: class insert_data
    RescardreservationTable rv = new RescardreservationTable();
    Could somebody please tell me how I can make servlet locate my java classes that it has to use?
    Thanks,
    Victor.
    Edited by: vic_sk on Dec 9, 2008 9:29 AM

    Ok, looks like it's solved. Just forcing the compiler with -classpath to look for the required class file.

  • Why we need to restart server when we compile servlet (not for jsp)

    hi
    why we need to restart server/appln when we compile servlet .
    same thing is not true for jsp
    as jsp converts to servlets then also it need not require restart of server/appln.
    Danny

    Dear Friends
    I hope you guys are doing something with tomcat , So please help me.
    can anyone solve my problem.
    I am starting my tomcat using startup and the dos window just closes after opening . I don't know why?
    The errors generated are as:
    Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: C:\jdk1.3.0_02
    Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
    java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
         at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.apache.commons.digester.Digester.parse(Digester.java:1548)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
         at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
         at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
    Using CATALINA_BASE: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_HOME: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29
    Using CATALINA_TMPDIR: C:\TOMCAT 4_1_30\jakarta-tomcat-4.1.29\temp
    Using JAVA_HOME: C:\jdk1.3.0_02
    Catalina.start: java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
    java.util.MissingResourceException: Can't find bundle for base name org.apache.coyote.tomcat4.LocalStrings, locale en_US
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2540)
         at org.apache.commons.digester.Digester.createSAXException(Digester.java:2566)
         at org.apache.commons.digester.Digester.startElement(Digester.java:1276)
         at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
         at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
         at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
         at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
         at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
         at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
         at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
         at org.apache.commons.digester.Digester.parse(Digester.java:1548)
         at org.apache.catalina.startup.Catalina.start(Catalina.java:449)
         at org.apache.catalina.startup.Catalina.execute(Catalina.java:400)
         at org.apache.catalina.startup.Catalina.process(Catalina.java:180)
         at java.lang.reflect.Method.invoke(Native Method)
         at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:203)
    i need your help desperately.
    I hope you will respond soon.
    thanks
    vishal

  • How to compile servlets

    well,actually the problem arises this way.i have installed the new version j2ee sdk which even contains j2se1.5.now when i compile the servlet program it says the package import http.servlet.*; does not exists.i even had set the classpath as C:\Sun\AppServer\jdk\lib\dt.jar;C:\Sun\AppServer\jdk\lib\tools.jar;C:\bea\weblogic81\server\lib\weblogic.jar;C:\bea\weblogic81\server\lib\webservices.jar;.;
    b'coz i m using web-server as weblogic so i even included it in the classpath.now wats the problem for compilation ,i tried all sorts of things but unable to solve.so plz some1 do post the solution as i m preparing for SWCD.

    well,actually the problem arises this way.i have
    installed the new version j2ee sdk which even
    contains j2se1.5.of course - jee cannot exist without jse.
    now when i compile the servlet
    program it says the package import http.servlet.*;
    does not exists.Because you need that package in your CLASSPATH and it's not, according to the compiler.
    i even had set the classpath as
    C:\Sun\AppServer\jdk\lib\dt.jar;C:\Sun\AppServer\jdk\l
    ib\tools.jar;C:\bea\weblogic81\server\lib\weblogic.jar
    ;C:\bea\weblogic81\server\lib\webservices.jar;.;I'm confused - you have WebLogic 8.1 as your JEE server. Why do you need the one from Sun? (Answer: You don't.)
    b'coz i m using web-server as weblogic so i even
    included it in the classpath.now wats the problem for
    compilation ,i tried all sorts of things but unable
    to solve.so plz some1 do post the solution as i m
    preparing for SWCD.You're preparing for SWCD and you don't know how CLASSPATH works? Oh, my.
    You should not use a system environment variable CLASSPATH. (I don't have one.) Use the -classpath option on javac.exe and java.exe when you compile and run, respectively. You should set the CLASSPATH each and every time you compile and run, because it changes with every application you write.
    If this becomes tedious, either put it in a script or learn how to use Ant.
    %

  • Compile Servlet

    when i try to compile servlet i got error message. it can't be identify servlet classes. why is that?
    some books mention about class path to fix that problem. but i can't understand.
    can any one explain little bit deep?
    * i am using windows xp and tomcat server.
    -thanks-

    hi,
    for example your tomcat in c:\tomcat5.0 means
    set classpath=c:\tomcat5.0\common\lib\servlet-api.jar
    or
    set classpath=c:\tomcat4.1\common\lib\servlet.jar
    or find servlet.jar or servlet-api.jar (thats depend upon your tomcat version)
    give classpath for that jar file
    and compile

  • Unable to compile servlet files in javac

    i am unable to compile servlet *.java files in javac.as far as i can see my path is correct.
    Kindly provide a solution as soon as possible.
    My jdk1.3 is in my c drive and my tomcat in my d drive.
    if you are able to compile kindly let me know your path.
    it says symbol not resolved.i think that it is unable to import from javax

    Assuming that your jdk is in c drive as c:\jdk1.3 set the path and the classpath like as shown below. Remember that you have to set the classpath for the classes in the javax.servlet and javax.servlet.http packages. I know how to do it for JavaWebServer. JavaWebServer has a jar called servlet.jar that contains all these classes. What you need to do is to put this jar file in your classpath. There will be a similar jar file for Tomcat server also. You need to refer the Tomcat server documentation for that.
    The path and the classpath have to be set like this...
    d:\>path=%path%;.;c:\jdk1.3\bin;
    d:\>set classpath=%classpath%;.;c:\jdk1.3\lib;c:\JavaWebServer2.0\lib\servlet.jar;
    assuming tht JWS is installed in c:\JavaWebServer2.0
    Also note that there should be no spaces in between while setting the classpath. In your case you have to change the last part of the classpath to customize your requirement.
    Hope that will help.
    Regards
    Jaydeep

  • Problem in Download Servlet (Urgent)

    Hai
    i am using an servlet to download files.
    i am facing an problem with that servlet.While downloading, at times it strucks at 290k or 330k.
    Note : Acually i am calling this servlet from a popup window.The popup window closes automatically after one minute irrescpective of the download progress.At times i noticed that the download strucks while the popup closes, whether is causes the problem of strucking.
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Download extends HttpServlet {
    HttpSession session =null;
    File F;
    BufferedInputStream fif;
    ServletOutputStream stream;
    public void init(){
    F=null;
    fif=null;
    stream =null;
    public void doGet(HttpServletRequest request ,HttpServletResponse response) {
    try{
         // Setting Buffer size
    response.setBufferSize(50000);
                   // Setting Content Type
    response.setContentType("application/x-filler");
    int buffersize;
    String cfile="";
    boolean flag=false;
    session = request.getSession(true);
                   //Receiving variables
    String fileName= request.getParameter("filename");
    String filePath = request.getParameter("filepath");
    String downloadFile = filePath + fileName;
    F=new File(downloadFile);
    String download_date = "sysdate";
    String file=F.getName();
    buffersize=(int)F.length();
    byte b[]=new byte[buffersize];
         //Servet output stream to download file
    stream = response.getOutputStream();
    response.setHeader("Content-Disposition", "attachment; filename=\"" + file + "\";");
    int data;
    fif = new BufferedInputStream(new FileInputStream(F));
    //writing data to output stream
    while((data = fif.read()) != -1) {
    stream.write(data);
                   //closing objects
    fif.close();
    stream.close();
    F.delete();
    }catch(java.net.SocketException se){
    System.out.println("SocketException " +se);
    catch(IOException io){
    System.out.println("IOException " + io);
    catch(Exception e){
    System.out.println("Exception " +e);      
    }

    I guess your closing of the window is your problem. Your servlet looks just fine to me.
    Try calling this servlet from a browser and see if it still stops..

  • Problem in compiling j2me file

    Hello friends,
    friends my problem in compiling j2me file..
    when i compile my j2me file through WTK2.2 (toolkit)
    then it creates extra file including j2me" .class" file..
    for example if my j2me file is "aman.java" and when i compile it
    then it will covert into "aman.class" file but it creates one more file like "aman1$.class" ..plz help me to get out of this problem..coz its increase my j2me file size..
    thanks
    Aman

    That is an inner class in aman.java that you are seeing there.
    If you use inner anonymous classes, for example;
    public class MyMIDlet extends MIDlet {
       // code for the MIDlet
       // Anonymous inner class
       setCommandListener(new CommandListener() {
          public void commandAction(Command c, Displayable d) {
            // implementation;
            // may access MyMIDlet's private fields
    }then the command listener you create will become another class named MyMIDlet$1.class.
    In this example you can get rid of the inner class by making one of the existing classes implement that CommandListener interface:
    public class MyMIDlet extends MIDlet implmements CommandListener {
       public void commandAction(Command c, Displayable d) {
         // implementation;
         // may access MyMIDlet's private fields
       // code for the MIDlet
       // Instead of the anonymous inner class, we can now use MyMIDlet since it
       // implements CommandListener
       setCommandListener(this);
       // etc. etc. etc.
    }shmoove

Maybe you are looking for

  • Can I use iCloud storage for iOS apps?

    Hello, I'm trying to work out if it's possible to use iCloud to save/load data across devices with iOS apps created using Air. I know there is a lot of talk about now meeting the Apple data storage guidelines eg http://www.saumitrabhave.com/2011/11/a

  • Not able to read the wsdl file from server Premature EOF encounter

    Hi All, I am facing issue while accessing a web Service from server. Here is the clear view about it. I created a simple SyncBpel process in a composite and deployed in to the server and it is working fine. Later i created a new Asyn bpel process in

  • Lost MAIL and address book!

    I couldn't open the program I use to make greeting cards. Read my OSX manual and read that I should reinstall OSX. I backed up everything (I thought!) When I opened up MAIL after the reinstallation, everything was gone...address book, saved e-mail, a

  • Missing letters in TM title

    I am a beginner in actionscript. I have readmore button displaying TM content I have wrote : _root.TM_title="abcdefhijk" But in a result title is only "ei" . It looks like problem with some characters. For tittle "aaabbb" - result nothing tittle "aae

  • Why does displayed data flicker?

    I am acquiring temperature from three RTDs and I want to display the real-time temperature on the front panel.  If i use the DAQ Express I have no problem doing so. However, I am trying to avoid using the DAQ Express and use DAQmx instead. On my fron