• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compiling servlet file

 
Varun Nayudu
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys i have just downloaded Editplus and want to know how to compile a servlet file .Please tell what needs to be done .I am getting a compiler error when i try to compile a simple servlet file


-------------------servlet file -------------------
package web.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class ser extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException ,ServletException{
System.out.println("------ in the ser.java servldet ---------");
}
}

------------------End of servlet file ----------------

---------- Java Compiler ----------
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:7: cannot find symbol
symbol: class HttpServlet
public class ser extends HttpServlet
^
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:9: cannot find symbol
symbol : class HttpServletRequest
location: class web.servlet.ser
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:9: cannot find symbol
symbol : class HttpServletResponse
location: class web.servlet.ser
public void doGet(HttpServletRequest request,HttpServletResponse response)
^
D:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\XYZ\WEB-INF\classes\web\servlet\ser.java:10: cannot find symbol
symbol : class ServletException
location: class web.servlet.ser
throws IOException ,ServletException{
^
6 errors

Output completed (1 sec consumed)


Please advice me what all needs to be done
 
Vinoth Thirunavukarasu
Ranch Hand
Posts: 164
Android Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I think you haven't set the class path for javax.servlet package. To compile a servlet you must specify class path.
 
Varun Nayudu
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I also have Gel and it dosnt give me any compiler error when i compile the servlet file i dont know where to set the classpath for Editplus

I want to know how to compile a servlet file in edit plus
 
Aum Tao
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have a look at ServletsFAQ

If it's an IDE specific question, you are better off posting it in the IDE forum.
[ December 20, 2008: Message edited by: Prateek Parekh ]
 
XinShou ShangLu
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Firsty,I never compile any java files in Editplus.

I think you must use 'servlet-api.jar'.This file should be in the '%tomcat%\lib\'.

You can specify like this : (I guess your tomcat directory is 'D:\Program Files\Apache Software Foundation\Tomcat 5.0\' LOL)
-classpath D:\Program Files\Apache Software Foundation\Tomcat 5.0\lib\servlet-api.jar
[ December 23, 2008: Message edited by: XinShou ShangLu ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic