If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > when I went to compile Servlets I get error below, where is the wrong

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-27-09, 10:16
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
when I went to compile Servlets I get error below, where is the wrong

I install JDK but when I went to compile Servlets I get error below, where is the wrong ? I compile/run success normal java...

Code:
C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>javac Test21.java

C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>java Test21
String test: str = hello

C:\J-DB-ACCESS\Servlets-JSPs\Chapter9\WEB-INF\classes>cd C:\J-DB-ACCESS\Servlets-JSPs\Chapter9

C:\J-DB-ACCESS\Servlets-JSPs\Chapter9>javac HelloPlantServlet.java
HelloPlantServlet.java:4: package javax.servlet does not exist
import javax.servlet.*;
^
HelloPlantServlet.java:5: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
HelloPlantServlet.java:7: cannot find symbol
symbol: class HttpServlet
public class HelloPlantServlet extends HttpServlet   {
                                       ^
HelloPlantServlet.java:10: cannot find symbol
symbol  : class HttpServletRequest
location: class HelloPlantServlet
   protected void doGet( HttpServletRequest request, //Executes in response to a "get" public
                         ^
HelloPlantServlet.java:11: cannot find symbol
symbol  : class HttpServletResponse
location: class HelloPlantServlet
       HttpServletResponse response )               //type of request from a Web client.
       ^
HelloPlantServlet.java:12: cannot find symbol
symbol  : class ServletException
location: class HelloPlantServlet
         throws ServletException, IOException
                ^
6 errors

C:\J-DB-ACCESS\Servlets-JSPs\Chapter9>
Reply With Quote
  #2 (permalink)  
Old 12-27-09, 11:33
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
Also the below what make it ? may not DSN working(localhost) in servlet or bad combilation or old java deprecated ? :

HTTP Status 404 - /flowerpowerget
--------------------------------------------------------------------------------
type Status report

message /flowerpowerget

description The requested resource (/flowerpowerget) is not available.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.18
Reply With Quote
  #3 (permalink)  
Old 12-27-09, 19:21
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
javac issues: Your CLASSPATH variable isn't set correctly.

apache issues: 404 means the resource isn't available. What resource did you expect to be there?
Reply With Quote
  #4 (permalink)  
Old 12-28-09, 00:31
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
"javac issues: Your CLASSPATH variable isn't set correctly." EVENT IF NORMAL JAVA COMPILES WELL LIKE
import java.sql.*;
import java.io.*;
I THINK ONLY servlet IMPORTS GIVE ERROR AND SOME servlet CLASSES, WELL ?
Other matter solved ...
Reply With Quote
  #5 (permalink)  
Old 12-29-09, 11:37
scooby_at_work scooby_at_work is offline
Registered User
 
Join Date: Sep 2009
Posts: 44
Quote:
Originally Posted by lse123 View Post
"javac issues: Your CLASSPATH variable isn't set correctly." EVENT IF NORMAL JAVA COMPILES WELL LIKE
import java.sql.*;
import java.io.*;
I THINK ONLY servlet IMPORTS GIVE ERROR AND SOME servlet CLASSES, WELL ?
Other matter solved ...
Java is searching for the servlet classes and it is not finding them.

Code:
package javax.servlet.http does not exist
This means that with every entry in CLASSPATH, java looked to see if it could find entry/javax/servlet/http. It looked inside any .jar files listed. It probably also looked in some default location, which is how it found the standard packages java.sql.* and java.io.*.

That's just how it works. You need to figure out where the servlet classes are and set your CLASSPATH variable to include them.

They ought to already be in your classpath. A common problem is if you have multiple JVMs installed. You have, guaranteed, 2 since you have a JRE and a JDK, probably more, and some OSs ship with 4 or 5 installed.

It is a huge pain in the butt, but you need to figure it out if you're going to use Java to do stuff. (Just about every language has some variant of this problem, incidentally.) Google "problem with classpath"; you're not the only one with this problem.
Reply With Quote
  #6 (permalink)  
Old 12-29-09, 12:20
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
I FOUND : servlet-api.jar in TOMCAT 6 (THIS ONLY NEEDED CORRECT?)
WHERE insert it to can compile SERVLETS ?

where added(directory), some folders follow...?

C:\Program Files\Java\jdk1.6.0_15\bin
C:\Sun\AppServer\lib
C:\Program Files\Java\jdk1.6.0_15\src\javax
Reply With Quote
  #7 (permalink)  
Old 12-29-09, 15:55
lse123 lse123 is offline
Registered User
 
Join Date: May 2007
Posts: 139
I FOUND : servlet-api.jar in TOMCAT 6 (THIS ONLY NEEDED CORRECT?)
C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.18\lib\servlet-api.jar

WHERE insert it(FOLDER) to can compile SERVLETS ?


TO set classpath in System Vars what to insert ? currently is:
.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip

another way is to copy servlet-api.jar to directory is servletsample.java (and this DIR USED TO COMPILE)?
Reply With Quote
  #8 (permalink)  
Old 01-11-10, 02:26
girishbs girishbs is offline
Registered User
 
Join Date: Apr 2008
Location: Bangalore, India
Posts: 23
Classpath needs to be updated

Some pointers to the classpath problem:
1. Ensure that you have downloaded JDK/J2EE and installed
2. Make sure that your PATH variable is set to the correct JAVA folder, the system default java installation may not contain servlet jars.
3. Set your CLASSPATH=%PATH%;<j2ee_directory/lib>/servlet-2.2.jar
__________________
--
Girish.B
Lytecube.com
code free application environments
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On