jQuery in Action, 2nd edition*
The moose likes Struts and the fly likes cannot find symbol Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Frameworks » Struts
Bookmark "cannot find symbol" Watch "cannot find symbol" New topic
Author

cannot find symbol

Biby Thoms
Ranch Hand

Joined: Jan 10, 2006
Posts: 48
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));
}
}
======================


Thanks<br />Biby Thoms
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

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...


A good workman is known by his tools.
Biby Thoms
Ranch Hand

Joined: Jan 10, 2006
Posts: 48
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
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
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?


Ping & DNS - my free Android networking tools app
Biby Thoms
Ranch Hand

Joined: Jan 10, 2006
Posts: 48
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
Marshal

Joined: Mar 22, 2005
Posts: 42023
    
  64
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

Joined: Jan 10, 2006
Posts: 48
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: cannot find symbol