• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

cannot find symbol : class HttpServletResquest

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone,

I am new to Servlets and i am trying to run a simple servlet program through command prompt.
But no idea what is the reason, i am getting compiler error as cannot find symbol : class HttpServletResquest.
Error is very clear that its classpath problem. i tried to compile the below servlet as mentioned below.

I have tried to set servlet-api.jar to classpath using javac -classpath option.

F:\Sample>javac -classpath ".;F:\Sample\lib\servlet-api.jar" -d classes src/TestServlet.java

Error:

src\TestServlet.java:7: cannot find symbol
symbol : class HttpServletResquest
location: class TestServlet
public void doGet(HttpServletResquest request,HttpServletResponse response) throws IOException
^
1 error


I know its problem with the classpath. I have also tried echo %classpath% which returned nothing.. Whats wrong with my classpath?

JAVA_HOME = C:\Java\jdk1.6.0_13
Path = C:\Program Files\PC Connectivity Solution\;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%JAVA_HOME%\bin\;


Can someone please help me.

Thanks a lot in advance.
Pradeep.

Here is my Servlet. FYI







 
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep Kumar Devar wrote:I have tried to set servlet-api.jar to classpath using javac -classpath option.
F:\Sample>javac -classpath ".;F:\Sample\lib\servlet-api.jar" -d classes src/TestServlet.java


Remove the quotes(" ") from the path entry for the -classpath.


I know its problem with the classpath. I have also tried echo %classpath% which returned nothing.. Whats wrong with my classpath?



If you haven't set it you'll get nothing . Setting the classpath as above only work for that specific command (javac in this case). You have to add a CLASSPATH environment variable just like PATH,JAVA_HOME for "echo %CLASSPATH%" to work.

 
Pradeep Kumar Devar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your Vijitha,

I have tried removing quotes in classpath entry as you suggested. But again same problem.

F:\Sample>javac -classpath .;F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java
.\src\TestServlet.java:7: cannot find symbol
symbol : class HttpServletResquest
location: class TestServlet
public void doGet(HttpServletResquest request,HttpServletResponse response) throws IOException
^
1 error


Could you please tel me what wrong.. I'v been trying this for long time..
Please help me.

Thanks in advance.
Pradeep
 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep Kumar Devar wrote:I have tried removing quotes in classpath entry as you suggested. But again same problem.
Could you please tel me what wrong.. I'v been trying this for long time..



Entry separator may be the cause (semi colon works for Vista), try : (colon) instead if not Vista.
 
Pradeep Kumar Devar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your immediate reply.Still i am not able to do it.

FYI, I am working on windows XP.

F:\Sample>javac -classpath F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java
.\src\TestServlet.java:7: cannot find symbol
symbol : class HttpServletResquest
location: class TestServlet
public void doGet(HttpServletResquest request,HttpServletResponse response) throws IOException
^
1 error

i have tried below ways.

F:\Sample>javac -classpath .:F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java
F:\Sample>javac -classpath .;F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java
F:\Sample>javac -classpath F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java

please help me.
 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep Kumar Devar wrote:
F:\Sample>javac -classpath F:\Sample\lib\servlet-api.jar -d classes ./src/TestServlet.java



This should work assuming servlet-api.jar resides in F:\Sample\lib\.

try this for the last time (but it's same as above).

F:\Sample>javac -classpath F:\Sample\lib\servlet-api.jar -d classes src\TestServlet.java


 
Pradeep Kumar Devar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One question.

If servlet-api.jar is not set to classpath, the compiler will throw errors at imports itself. Am i rite?
In this case it is pointing to HttpServletRequest. There could be some reasons for this?

Please tell me if i am wrong.

Pradeep.
 
Pradeep Kumar Devar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Again it didn't work.

F:\Sample>javac -classpath F:\Sample\lib\servlet-api.jar -d classes src\TestServlet.java
src\TestServlet.java:7: cannot find symbol
symbol : class HttpServletResquest
location: class TestServlet
public void doGet(HttpServletResquest request,HttpServletResponse response) throws IOException
^
1 error



 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Pradeep Kumar Devar wrote:public void doGet(HttpServletResquest request,HttpServletResponse response) throws IOException



My Bad. I didn't try your code . Do you see something wrong in that highlighted word ? It should be HttpServletRequest. Well now it definitely should work.
 
Pradeep Kumar Devar
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh god. Its such a silly typo mistake .

Thanks a lot for your time.I really appreciate your help.
Its working now.. Of course it will

Pradeep
 
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! am also a newbie. This helped me too!
 
Vijitha Kumara
Bartender
Posts: 4109
72
Hibernate Fedora Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Aseem
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic