aspose file tools*
The moose likes Beginning Java and the fly likes problem in compiling servlet/jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "problem in compiling servlet/jsp" Watch "problem in compiling servlet/jsp" New topic
Author

problem in compiling servlet/jsp

pankaj goswami
Greenhorn

Joined: Oct 10, 2007
Posts: 16
i have sun application server and tomcat both. i wrote program of servlet but when i am compiling it .it is saying import servlet package etc. i want to know;-

1) what setting i have to do after installing sun application server and tomcat on computer so that my program(servlet/jsp) compile properly?

2) and how i do that?

i have window xp sp2
location of my sun application server installed is=D:\Sun\AppServer
location of my tomcat server is =D:\program files\Apache Software Foundation\Tomcat 6.0


please tell me i am tring form so many days. please helppppppppp .me

thank you. looking for your replies.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Hi pankaj goswami,

We have a FAQ entry with some information on compiling servlets that you might find helpful.

http://faq.javaranch.com/java/CompilingServlets

I'm going to move this to our Java In General (Beginner) forum where javac, and classpath issues are discussed.

-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
pankaj goswami
Greenhorn

Joined: Oct 10, 2007
Posts: 16
i add my class path as:

start->my computer->properties->advance->environment variables- select class path->and than i write my application server drive path i.e(D:\Sun\AppServer\lib\j2ee.jar.


but when i compile servlet program it says again and again import servlet package etc.

is i am setting class path wrong. and if am i. what is correct one.

thanks in advance.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Open up a command window and type:


It should print your classpath.
See if that matches the path to your j2ee.jar file.
krishnamoorthy kitcha
Ranch Hand

Joined: Feb 04, 2006
Posts: 96
Dear pankaj goswami


Can you show to us , what exception should be thrown while in the compile time ?

Because, if you are using servlet t, you should import all servlet package like

import javax.servlet.http.*
or
import javax.servlet.*

which is available in the tomcat server or j2ee server .

Check and tell me your feedback.
pankaj goswami
Greenhorn

Joined: Oct 10, 2007
Posts: 16
here is error which it is showing to me.

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\PANKAJ>


C:\Documents and Settings\PANKAJ>f:

F:\>javac EmployeeDetails.java
EmployeeDetails.java:3: package javax.servlet does not exist
import javax.servlet.*;
^
EmployeeDetails.java:4: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
EmployeeDetails.java:5: cannot find symbol
symbol: class HttpServlet
public class EmployeeDetails extends HttpServlet
^
EmployeeDetails.java:9: cannot find symbol
symbol : class PrinterWriter
location: class EmployeeDetails
PrinterWriter out;
^
EmployeeDetails.java:10: cannot find symbol
symbol : class Resultset
location: class EmployeeDetails
Resultset rs;
^
EmployeeDetails.java:18: cannot find symbol
symbol : class HttpServletRequest
location: class EmployeeDetails
public void doGet(HttpServletRequest request,HttpServletResponse Response)throws
ServletException,IOException
^
EmployeeDetails.java:18: cannot find symbol
symbol : class HttpServletResponse
location: class EmployeeDetails
public void doGet(HttpServletRequest request,HttpServletResponse Response)throws
ServletException,IOException
^
EmployeeDetails.java:18: cannot find symbol
symbol : class ServletException
location: class EmployeeDetails
public void doGet(HttpServletRequest request,HttpServletResponse Response)throws
ServletException,IOException

^
EmployeeDetails.java:21: cannot find symbol
symbol : variable response
location: class EmployeeDetails
out=response.getWriter();
^
EmployeeDetails.java:25: cannot find symbol
symbol : method forname(java.lang.String)
location: class java.lang.Class
Class.forname("sun.jdbc.odbc.jdbcodbcDriver");
^
EmployeeDetails.java:30: cannot find symbol
symbol : method preparedStatement(java.lang.String)
location: interface java.sql.Connection
pstmt=con.preparedStatement(query);
^
EmployeeDetails.java:31: cannot find symbol
symbol : variable Integer
location: class EmployeeDetails
pstmt.setInt(1,Integer,parseInt(request.getParameter("id")));
^
EmployeeDetails.java:34: cannot find symbol
symbol : method getMetaData()
location: class EmployeeDetails
ResultSetMetaData rsmd=rs=getMetaData();
^
EmployeeDetails.java:36: cannot find symbol
symbol : variable put
location: class EmployeeDetails
put.println("<TABLE ALIGN=CENTRE BORDER=1 CELLPADDING=2>");
^
14 errors

F:\>
pankaj goswami
Greenhorn

Joined: Oct 10, 2007
Posts: 16
yes when i am writting echo%classpath%.it is matching.so where i am going wrong
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in compiling servlet/jsp