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));
}
}
======================