Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem with servlet  RSS feed

 
Emmanuel Okandeji
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello
please am new to servlet and i am having problem compiling it. i have configured my path, classpath, java_home and tomcat_home but still it isn't working. please i have gone through some tutorials but still i just cant get it.

i added these paths to my system variables...
CLASSPATH : C:\Program Files\java\tomcat\common\lib\servlet-api.jar\;
C:\Program Files\Java\tomcat\common\lib\jsp-api.jar

PATH : C:\Program Files\java\tomcat\bin

i also created and added these path to my user variables...
JAVA_HOME : C:\Program Files\java\jdk1.6.0_06

TOMCAT_HOME : C:\Program Files\java\tomcat

please i will be very greatfull if someone could give me a guide to installing it...

thanks in advance...
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a "\" after servlet-api.jar in your classpath. Please remove it.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Emmanuel Okandeji welcome to Javaranch,
Quick tip:- please go through the Javaranch beginners faq and the sevlet faq.


Hope this helps .
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 15861
81
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Emmanuel.

You can find the FAQs that Amit is talking about here:
Java Beginners FAQ
Servlets FAQ
 
Jetendra Ivaturi
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi could you share your error.

or do this in your command prompt where you are trying to compile your servlet.

Before compiling set the class path like this:
prompt> set classpath=.;%classpath%;c:\pf\...\lib\servlet-api.jar;

... ==> represents the exact location of .jar file.

prompt> javac -d .\web-inf\classes filename.java
 
Emmanuel Okandeji
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,
thanks for all the help, i tried everything but the thing still isn't working...
Servan Kumar : i removed the "\" at the end but still it didn't compile...
Jasper young : i have gone throw all the tutorials but still it's giving me the same thing...

i tried using command line but because of the IDE (Jcreator) i am using it wouldn't compile if i used "javac" but if i try compiling with the IDE i get errors...

well this is the code i used----

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

public class FirstServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws IOException,ServletException {
response.setContentType("text/HTML");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Simple Servlet</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<BR><BR><BR>");
out.println("<CENTER><H1>A Simple Servlet</H1></CENTER>");
out.println("</BODY>");
out.println("</HTML>");
out.flush();
}
}

These are the Errors i got....

package javx.servlet does not exist
package javax.servlet does not exist
package javax.servlet.http does not exist
cannot find symbol
cannot find symbol class HttpServletRequest
cannot find symbol class HttpServletResponse
cannot find class ServletException
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It occur because the servlet libraries is not available in your classpath. as others are already pointed you about the FAQs. there is an entry about " classpath" which may help you to resolve this problem.

or do search on Google about how to add libraries in JCreator IDE.

hope it helps.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
Emmanuel Okandeji
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry for the Mix-code am really new to javaranch so am still learning how to use things. Sorry again...
this is the code again...
i added all the classes in the common\lib but still the same thing

please i really need someone to give me a guide tour, as in what things to put and where to put them please....

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65828
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code is immaterial. How are you compiling? What's your classpath and what command are you using to compile?
 
sandeep Kumar
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Emmanuel Okandeji,

Try to put the path of servlet-api.jar in tool's variable(Eg: In Eclipse, you need to put the path of servlet-api.jar in windows->preferences->java->Build path->classpath variables).Similarly you may set for JCreator. I am not aware of JCreator. I think this should resolve your issue.

Regards,
Sandeep.
 
V Sahdev
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Although this mightnot be the cause to you problem, but why are you having JDK & Tomcat sitting in the same directory ?
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi V Sahdev welcome to Javaranch,
Your name name does not follow the Javaranch Naming policy .
Please change it here.
Also take some time to go through the faq link posted above.

Thanks .
 
Emmanuel Okandeji
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Thanks all, i did it finally... You all are really great thanks again
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i did it finally...


sound.

 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amit Ghorpade:
Hi V Sahdev welcome to Javaranch,
Your name name does not follow the Javaranch Naming policy .
Please change it here.
Also take some time to go through the faq link posted above.

Thanks .


The display name is fine, we allow leading but not trailing initials, although we prefer full names.
 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops
my mistake, sorry for that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!