Click here to Skip to main content
15,886,861 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have created a java servlet program name dbsrv.java. I put it on Tomcat 7.0\webapps\ROOT\WEB-INF\classes\FirstServlet.java and also I set the class path for servlet-api.jar but when I compile it

C#
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

D:\tomcat7\webapps\dbsrv\web-inf\class>javac -d . dbsrv.java
dbsrv.java:3: error: package javax.servlet does not exist
import javax.servlet.*;
^
dbsrv.java:4: error: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
dbsrv.java:8: error: cannot find symbol
public class dbsrv extends HttpServlet{
                           ^
  symbol: class HttpServlet
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{
                          ^
  symbol:   class HttpServletRequest
  location: class dbsrv
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{
                                                 ^
  symbol:   class HttpServletResponse
  location: class dbsrv
dbsrv.java:29: error: cannot find symbol
        public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{

^
  symbol:   class ServletException
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{
                           ^
  symbol:   class HttpServletRequest
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{
                                                  ^
  symbol:   class HttpServletResponse
  location: class dbsrv
dbsrv.java:57: error: cannot find symbol
        public void doPost(HttpServletRequest req,HttpServletResponse res)throws
 ServletException,IOException{

 ^
  symbol:   class ServletException
  location: class dbsrv
9 errors

D:\tomcat7\webapps\dbsrv\web-inf\class>
Posted
Updated 24-Oct-14 5:53am
v3
Comments
Richard MacCutchan 24-Oct-14 11:15am    
You need to add the location of the javax package to your classpath.

1 solution

Cross Post:

while compiling code java:32: error: illegal start of expression[^]

have you followed the advice there?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900