• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to set class path

 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have installed j2sdk1.4.2_09 and tomcat 5.0.28.exe
how should I set the path and class path.
I have written a simple servlet but when i compile the program i get error (for eg.)can not resolve symbol HttpServlet

pls help me out.
 
Ner min
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rightclick my computer on your desktop, chose properties, click on the advenced tab, and then on enviroment variables
set new var CATALINA_HOME=C:\tomcat5(or so)
set new var java_HOME=C:\j2sdk1.4.2_09(or so)
set new var =CLASSPATH=%CATALINA_HOME%\common\lib\servlet-api.jar;%CATALINA_HOME%\common\lib\jsp-api.jar;.;..\classes
add to youre Path var %JAVA_HOME%\bin;
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks neir..
but are these variable to be declared under system variable or user variable.
 
Ner min
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sys of course
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thanks Neir, It worked. I can compile servlet..
I am calling servlet from html page. wrote deployment descriptor web.xml and keep it under web-inf directory under tomcat..but my html is not calling servlet..

can u tell me what is the probs?

actually i am using HFSJ and following code in chapter 3.
 
MI Mohammed
Ranch Hand
Posts: 146
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rekha,
I just want give another option, bara borne wayout,
It is not always advicible to alter your system classpath
for security reasons. Learn to use the javac and java -classpath
options.
There is a servlet-api.jar that defines anything servlet.
Check your tomcat common lib for the jar file and add it to the -classpath option and it works. eg

To compile MyServlet.java, the steps;

javac -classpth C:/tomcatDir/common/lib/servlet-api.jar; -d classes MyServlet.java.

make sure you have a classes dir in the same folder, where you servlet is.
The compiler automatically use the package statement to create a file structure for you.

Bareborne, gives you control.

SCJP 1.4 SCJA 1.0
 
Priya Jothi
Ranch Hand
Posts: 168
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rekha,

Post ur HTML code & servlet mapping part from web.xml.So that we can see what is wrong in it.

Regards,
Priya.
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Mohammed and priya..

I think probs is with my tomcat settings. Bcz the JSP example comes with tomcat are also not working.

Here is my HTML and web.xml code

html code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<BODY>
<h1 align="center"> Beer selection Page </h1>
<form method="POST"
action="SelectBeer.do">
Select Beer Chracteristics <p>
color:
<select name="color" size="1">
<option>light
<option>amber
<option>brown
<option>dark
</select>
<br><br>
<center>
<input type="SUBMIT">
</center>
</form>

</BODY>
</HTML>


web.xml:


<?xml version="1.0" encoding="ISO-8859-1" ?>


<web-app>


<servlet>
<servlet-name>ch3 Beer</servlet-name>
<servlet-class>com.example.web.BeerSelect</servlet-class>
</servlet>


<servlet-mapping>
<servlet-name>ch3 Beer</servlet-name>
<url-pattern>/SelectBeer.do</url-pattern>
</servlet-mapping>

</web-app>
 
Michael Alen Chang
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rekha,
Where is your servlet class? in your web DD, the BeerSelect.class must place in WEB-INF\classes\com\example\web

Regards,
Michael
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BeerSelect.class is in same directory as u mentioned.
 
Bimal Patel
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Rekha,

Can you paste the exception you're getting?
 
Rekha Gaikwad
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys , my code worked..actually it was minor mistake in class path. thanks for ur support.

Rekha
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic