• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what's wrong with this?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.io.*;
import javax.Servlet.*;
import javax.Servlet.http.*;
public class HelloWorld 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("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
what i swrong with my above program?

iam getting the following error:
import javax.Servlet.http;
^
HelloWorld.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class HelloWorld
public class HelloWorld extends HttpServlet {
^
HelloWorld.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorld.java:7: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorld.java:8: cannot resolve symbol
symbol : class ServletException
location: class HelloWorld
throws IOException, ServletException
^
6 errors
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import javax.Servlet.*;
import javax.Servlet.http.*;

should be:
import javax.servlet.*;
import javax.servlet.http.*;
see the difference.........
regds.
- saya
 
k b
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Looks like servlet.jar is missing from your class path, if so add c:/whereitis/servlet.jar to the class path and try compiling again.
Hope this helps.
 
krishna akula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i made those changes and also included
c:\software\tomcat\lib\servlet.jar
in the classpath.
still the same result iam getting.
 
krishna akula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Looks like nobody interested in answering my question.
there is no servlet.jar in my jdk1.3.0_02\lib.
I think i need to have servlet.jar in my jdk1.3.0_02\lib to my servlet work properly.
correct me if i am wrong.
 
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Krishna,
This is my classpath setting in c:\autoexec.bat file in win98 platform. We can keep the servlet in any dir.But that dir must be in classpath. I have servlet.jar as C:\jakarta-tomcat\lib\servlet.jar.Just make a search in your file system to see if there are 2 versions of servlet.jar which are in classpath.
Did you install jsdk/jswdk also in your machine? Sometimes the servlet.jar which came with old jsdk , give lots of headache when we try to use Tomcat.
If you find any other servlet.jar other than the one came with Tomcat just rename them and see.
regds
maha anna


[This message has been edited by maha anna (edited March 31, 2001).]
 
krishna akula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i don't have jsdk in my machine.and also my autoexec has,
C:\PROGRA~1\NETWOR~1\MCAFEE~1\SCAN.EXE C:\
@IF ERRORLEVEL 1 PAUSE
set JAVA_HOME=c:\jdk1.3.0_02
set path=c:\jdk1.3.0_02\bin
set TOMCAT_HOME=c:\software\tomcat
set class_path=c:\jdk1.3.0_02\lib\tools.jar
set class_path=%class_path%;c:\raji
set class_path=%class_path%;c:\software\tomcat\lib\servlet.jar
what is the problem then?
 
Ranch Hand
Posts: 324
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Krishna, did you make the changes suggested by Madhav i.e. did you change capital S to small s in the import statements? i.e. did you change Servlet to servlet?
Are the error messages exactly the same? If both the code and error messages have changed then maybe you could post them.
 
krishna akula
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my code:
--------------------------------------------------------------
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld 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("<body>");
out.println("<head>");
out.println("<title>Hello World!</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hello World!</h1>");
out.println("</body>");
out.println("</html>");
}
}
And this is the error message iam getting :
________________________________________________
import javax.servlet.http.*;
^
HelloWorld.java:5: cannot resolve symbol
symbol : class HttpServlet
location: class HelloWorld
public class HelloWorld extends HttpServlet {
^
HelloWorld.java:7: cannot resolve symbol
symbol : class HttpServletRequest
location: class HelloWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorld.java:7: cannot resolve symbol
symbol : class HttpServletResponse
location: class HelloWorld
public void doGet(HttpServletRequest request, HttpServletResponse response)
^
HelloWorld.java:8: cannot resolve symbol
symbol : class ServletException
location: class HelloWorld
throws IOException, ServletException
^
6 errors
And this is my autoexec.bat:
___________________-----_________________________________________

C:\PROGRA~1\NETWOR~1\MCAFEE~1\SCAN.EXE C:\
@IF ERRORLEVEL 1 PAUSE
set JAVA_HOME=c:\jdk1.3.0_02
set path=c:\jdk1.3.0_02\bin
set TOMCAT_HOME=c:\software\tomcat
set class_path=c:\jdk1.3.0_02\lib\tools.jar
set class_path=%class_path%;c:\raji
set class_path=%class_path%;c:\software\tomcat\lib\servlet.jar
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey,
since anna had given u the classpath it might be right,what i doubt is what did u save the file as helloworld.java or Hello
World.java,this might lead to cannot resolve symbol HelloWorld,check it out,else sorry,i have not checked ur classpath since anna had given u the solution.

rm
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I think problem is with the dir structure.There is always "jakatas-tomcat-3.2.1" dir created wherever you install tomcat.So I think it should be
"c:\software\tomcat\jakarta-tomcat-3.2.1\lib\servlet.jar"
instead of c:\software\tomcat\lib\servlet.jar.
If the problem pesists reinstall tomcat on root so that claspath will be c:\jakarta-tomcat-3.2.1\lib\servlet.jar.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this,posted previously by some one.It helped me.
move/copy the servlet.jar file manually to the %JAVA_HOME%\jre\lib\ext folder.If you do this you donot need to set the classpath for javax.servlet.* packages, as the Java Run-time environment would find it for you.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Neelu Bothra your suggestion solved my problem
 
Your mother was a hamster and your father was a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic