| Author |
problem in compiling my program
|
ganesh pol
Ranch Hand
Joined: Apr 29, 2005
Posts: 151
|
|
friends i have one of my class whose name is LoginServlets.java in C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets it uses costant class named Constants.class in C:\Ganesh_projects\LeaveManagement\Classes\com\leaveapp\utils source code for LoginServlets.java is package com.leaveapp.servlets ; import java.io.*; import javax.servlet.ServletException; import javax.servlet.http.*; import java.util.*; import com.leaveapp.utils.*;<<-------shows Error /* this is Servlet used to check whether user is valid or not for that it uses password as Key */ public class LoginServlets extends HttpServlet { Map users= new Hashtable(); public void init() { users.put("ganesh","g.pol"); users.put("poonam","p.gupta"); users.put("vivek","v.padh"); users.put("jayesh","j.khanvilkar"); } public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { /*getting parameters from request */ String un=req.getParameter(Constants.USER_NAME); <-- Error area String pw=req.getParameter(Constants.USER_PASSWORD);<-- Error area res.setContentType("text/html"); PrintWriter out= res.getWriter(); out.println("<html><head>"); out.println("<title>Result Page</title>"); out.println("</head>"); out.println("<body>"); /* this is used to Retrieve username associated with password */ String s1=(String) users.get(pw); /* processing Parameters*/ if(un != null && pw != null && un.equals((String) users.get(pw))) { out.println(" <center>you are valid user</center>"); } else { out.println("either you might type wrong username or password<BR> "); out.println("therefore System do not allow you to use System<BR>"); out.println(" Please use Back button and try again<BR>"); } } } source code for Constants.java is package com.leaveapp.utils; /*this is constant file for whole whole Leave application*/ public class Constants { /* parameters*/ public static final String USER_NAME="username"; public static final String USER_PASSWORD="password"; /* Std actions */ public static final String DELETE="delete"; public static final String ACCEPT="accept"; public static final String REJECT="reject"; public static final String CANCEL="cancel"; public static final String EDIT="edit"; public static final String SAVE="save"; public static final String SEND="send"; public static final String SUBMIT="submit"; public static final String COMPANY="company"; public static final String PROJECT="project"; public static final String INDIVIDUAL="idividual"; public static final String REMOVE="remove"; } Constants.java file compiles easily but when i try to compile LoginServlets.java it gives three errors C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp>cd servlets C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> javac LoginServlets.java LoginServlets.java:7: package com.leaveapp.utils does not exist import com.leaveapp.utils.*; ^ LoginServlets.java:28: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String un=req.getParameter(Constants.USER_NAME); ^ LoginServlets.java:29: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String pw=req.getParameter(Constants.USER_PASSWORD); ^ 3 errors C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> then i have set classpath C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets>set classpath=C:\Ganesh_projects\LeaveManagement\ es\com\leaveapp\utils;.; C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> javac LoginServlets.java LoginServlets.java:4: package javax.servlet does not exist import javax.servlet.ServletException; ^ LoginServlets.java:5: package javax.servlet.http does not exist import javax.servlet.http.*; ^ LoginServlets.java:7: package com.leaveapp.utils does not exist import com.leaveapp.utils.*; ^ LoginServlets.java:11: cannot resolve symbol symbol : class HttpServlet location: class com.leaveapp.servlets.LoginServlets public class LoginServlets extends HttpServlet ^ LoginServlets.java:24: cannot resolve symbol symbol : class HttpServletRequest location: class com.leaveapp.servlets.LoginServlets public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { ^ LoginServlets.java:24: cannot resolve symbol symbol : class HttpServletResponse location: class com.leaveapp.servlets.LoginServlets public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { ^ LoginServlets.java:24: cannot resolve symbol symbol : class ServletException location: class com.leaveapp.servlets.LoginServlets public void doPost(HttpServletRequest req, HttpServletResponse res) throws IOException,ServletException { ^ LoginServlets.java:28: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String un=req.getParameter(Constants.USER_NAME); ^ LoginServlets.java:29: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String pw=req.getParameter(Constants.USER_PASSWORD); ^ 9 errors C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> now it does not identify my servlets jar file now i have Set class path again C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets>set classpath=C:\Program Files\Apache Group\Tomcat 4.1 \common\lib\servlet.jar;C:\Ganesh_projects\LeaveManagement\Classes\com\leaveapp\utils C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> javac LoginServlets.java LoginServlets.java:7: package com.leaveapp.utils does not exist import com.leaveapp.utils.*; ^ LoginServlets.java:28: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String un=req.getParameter(Constants.USER_NAME); ^ LoginServlets.java:29: cannot resolve symbol symbol : variable Constants location: class com.leaveapp.servlets.LoginServlets String pw=req.getParameter(Constants.USER_PASSWORD); ^ 3 errors C:\Ganesh_projects\LeaveManagement\Src\com\leaveapp\servlets> PLZ help me and i do'nt want to create jar file
|
 |
ganesh pol
Ranch Hand
Joined: Apr 29, 2005
Posts: 151
|
|
friends i have got hte solution ihave to set path C:\Ganesh_projects\LeaveManagement\Classes; not upto utils package
|
 |
Marilyn de Queiroz
Sheriff
Joined: Jul 22, 2000
Posts: 9033
|
|
Thank you for sharing your solution.
|
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
|
 |
 |
|
|
subject: problem in compiling my program
|
|
|