• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot find symbol

 
Biby Thoms
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to JSP and Servlet.Also I am not sure whether I have to post these questions here. If not, my appologies....

I am trying to Run one sample from "WILEY - MASTERING JAKARTA STRUTS". I have two class and the source is attached below.
LookupForm class is running fine. I am not able to run the LookupAction class. I am always getting the following error

=======================
D:\Tomcat\webapps\wileystruts\wiley\LookupAction.java:26: cannot find symbol
symbol : class LookupForm
location: class wiley.LookupAction
LookupForm lookupForm = (LookupForm)form;
^
D:\Tomcat\webapps\wileystruts\wiley\LookupAction.java:26: cannot find symbol
symbol : class LookupForm
location: class wiley.LookupAction
LookupForm lookupForm = (LookupForm)form;
^
2 errors

Tool completed with exit code 1

=======================
http://localhost:8080/wileystruts/Lookup.do;jsessionid=3727A08A7B5CE3D66024E24F0D94D783. Also I am getting "HTTP Status 404 - Servlet action is not available". Do you have any idea?

======================
package wiley;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class LookupForm extends ActionForm {
private String symbol = null;
public String getSymbol() {
return (symbol);
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public void reset(ActionMapping mapping,HttpServletRequest request) {
this.symbol = null;
}
}

=====================
package wiley;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class LookupAction extends Action {
protected Double getQuote(String symbol) {
if ( symbol.equalsIgnoreCase("SUNW") ) {
return new Double(25.00);
}
return null;
}
public ActionForward execute(ActionMapping mapping,ActionForm form,HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
Double price = null;
// Default target to success
String target = new String("success");
if ( form != null ) {
// Use the LookupForm to get the request parameters

LookupForm lookupForm = (LookupForm)form;
String symbol = lookupForm.getSymbol();
price = getQuote(symbol);
}
// Set the target to failure
if ( price == null ) {
target = new String("failure");
}
else {
request.setAttribute("PRICE", price);
}
// Forward to the appropriate View
return (mapping.findForward(target));
}
}
======================
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The URL isn't going to work because the classes aren't even compiling. It appears the LookupAction is complaining because it can't find LookupForm. Are you sure you're compiling them both together?

I'll move this over to the Struts forum in the meantime...
 
Biby Thoms
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.

I am able to complie "LookupForm.java" without any problem(Compiled using Textpad). But I am not able to compile the second java file. Both are residing in the same package.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What command are you using to compile the files? In which directory (relative to the one you're issuing the compile command in) are they?
 
Biby Thoms
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Files
D:\Textpad\wiley\LookupForm.java
D:\Textpad\wiley\LookupForm.class
D:\Textpad\wiley\LookupAction.java


then other directory inside wiley for org...
D:\TextPad\wiley\org\apache\struts...action,actions...webapp....


I have the similar setup in the webapps...but I am trying to complie the LookupAction.java from Textpad.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The directory structure looks wrong to me. If the Java files are in package "wiley", then the "org/apache/..." hierarchy should be inside the "textpad" directory, not inside of "wiley".

Textpad is probably not smart enough to figure out how to access other class files. Open a command prompt in the "Textpad" directory, and type "javac wiley/*.java"
 
Biby Thoms
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. But now I have the following error while accessing http://localhost:8080/wileystruts/Lookup.do Do you guys have any idea?


HTTP Status 404 - Servlet action is not available

type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.


Please help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic