Compilation Error in STRUTS
Hello,
I don't no wthr this is rit place to ask problem relating struts, but since i found some previous queries frm struts here, i'm also putting my simple question hoping to get response.
I'm a newbie in struts, i was trying an application given in "struts complete reference".This is my code of Controller class(Action class):-
package com.jamesholmes.struts;
import java.util.ArrayList;
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 final class SearchAction extends Action
{
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
throws Exception
{
EmployeeSearchService service = new EmployeeSearchService();
ArrayList results;
SearchForm searchForm = (SearchForm) form;
//Perform employee search based on what criteria was entered.
String name = searchForm.getName();
if(name != null && name.trim().length() > 0)
{
results = service.searchByName(name);
}
else
{
results = service.searchBySsNum(searchForm.getSsNum().trim());
}
//place search results in SearchForm for access by jsp.
searchForm.setResults(results);
//Forward control to this Action's input page.
return mapping.getInputForward();
}
}
Now problem is when i'm compiling this java file i'm getting error"can not resolve symbol" for the instances i'm creating for SearchForm(view class) and EmployeeSearchService(model class).can any one help me how to resolve this problem.
[1882 byte] By [
Garva] at [2007-11-27 4:45:50]

# 3
I'm guessing it is a classpath issue.
Are you using an IDE (Eclipse/Netbeans) to compile the code, or are you using the command line javac?
Have you included struts.jar in the classpath?
Have you included your current working directory in the classpath?
Lets say you have your class in java/src/com/jamesholmes/struts/SearchAction.java
From the directory :java/src
javac -cp [struts.jar]:. com/jamesholmes/struts/*.java
Or something like that at least :-)
Hope this helps,
evnafets
# 4
Hi,
problem for compiling package solved.But now when i'm making the WAR file of the application and tryin to run it thru tomcat(i placed this WAR file into tomcat's webapps directory)i'm getting some server Exception which i'm not at all able to get.Guys just help me gettin out of this hell HHTP status 500, what is this error actually.Here is the error :-
HTTP Status 500 -
--
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
java.lang.NullPointerException
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:521)
org.apache.struts.util.RequestUtils.computeURL(RequestUtils.java:436)
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:495)
org.apache.struts.taglib.html.LinkTag.doStartTag(LinkTag.java:353)
org.apache.jsp.index_jsp._jspx_meth_html_link_0(index_jsp.java:96)
org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.27 logs.
--
Apache Tomcat/5.0.27
Garva at 2007-7-12 9:58:17 >
