V
Vitthal Bhat via JavaKB.com
hi Everybody,
I am new to struts.
I want to display a dropdown window in JSP page.
My JSP Code IS (Site1.jsp is name of the form name)
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<HTML>
<BODY>
<html:form action="Site1">
<TD class="label" colspan="1" style="color:#000000"><bean:message key="Site1.phCountryCode" />
</TD>
<td>
<html:select property="phCountryCode">
<htmlptions collection="phcountry" property="value" labelProperty="label"/>
</html:select>
--------------------------------------------------------
--- my phcountry bean class is--
public class phcountry extends ActionForm{
private int id;
private String phcountryname;
public phcountry( int id, String phcountryname ) {
this.id = id;
this.phcountryname = phcountryname;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getphcountryname() {
return phcountryname;
}
public void setphcountryname(String phcountryname) {
this.phcountryname = phcountryname;
}
}
-----------------------------------------------------------------
my helper Class name is SiteHelper as given below
public class SiteHelper
{
public Collection getphcountry() {
ArrayList list = new ArrayList(3);
list.add( new phcountry( 93, "Afghanistan"));
list.add( new phcountry( 91, "India"));
list.add( new phcountry( 01, "U.S.A"));
return list;
}
}
_________________________________
my action class is SiteAction as given below
import java.util.Collection;
import javax.servlet.http.HttpSession;
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;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SiteAction extends Action
{
private static Log log = LogFactory.getLog(SiteAction.class);
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
SiteHelper isitehelper=new SiteHelper();
Collection phcountry = isitehelper.getphcountry();
request.setAttribute( "phcountry", phcountry );
return mapping.findForward("success");
}
}
i comple the program using Ant tool and giving message Build Successfully
once i run the jsp page thru Tomcat 5.0 its giving error like.
description: The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl .java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.j ava:758)
org.apache.jsp.Site1_jsp._jspService(Site1_jsp.java:99)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
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:810)
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:711)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:419)
org.apache.jsp.Site1_jsp._jspx_meth_html_form_0(Site1_jsp.java:115)
org.apache.jsp.Site1_jsp._jspService(Site1_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
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:810)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.
So please help me to populate Drop down box in my JSP page
I am new to struts.
I want to display a dropdown window in JSP page.
My JSP Code IS (Site1.jsp is name of the form name)
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<HTML>
<BODY>
<html:form action="Site1">
<TD class="label" colspan="1" style="color:#000000"><bean:message key="Site1.phCountryCode" />
</TD>
<td>
<html:select property="phCountryCode">
<htmlptions collection="phcountry" property="value" labelProperty="label"/>
</html:select>
--------------------------------------------------------
--- my phcountry bean class is--
public class phcountry extends ActionForm{
private int id;
private String phcountryname;
public phcountry( int id, String phcountryname ) {
this.id = id;
this.phcountryname = phcountryname;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getphcountryname() {
return phcountryname;
}
public void setphcountryname(String phcountryname) {
this.phcountryname = phcountryname;
}
}
-----------------------------------------------------------------
my helper Class name is SiteHelper as given below
public class SiteHelper
{
public Collection getphcountry() {
ArrayList list = new ArrayList(3);
list.add( new phcountry( 93, "Afghanistan"));
list.add( new phcountry( 91, "India"));
list.add( new phcountry( 01, "U.S.A"));
return list;
}
}
_________________________________
my action class is SiteAction as given below
import java.util.Collection;
import javax.servlet.http.HttpSession;
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;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SiteAction extends Action
{
private static Log log = LogFactory.getLog(SiteAction.class);
public ActionForward execute(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception
{
SiteHelper isitehelper=new SiteHelper();
Collection phcountry = isitehelper.getphcountry();
request.setAttribute( "phcountry", phcountry );
return mapping.findForward("success");
}
}
i comple the program using Ant tool and giving message Build Successfully
once i run the jsp page thru Tomcat 5.0 its giving error like.
description: The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl .java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.j ava:758)
org.apache.jsp.Site1_jsp._jspService(Site1_jsp.java:99)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
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:810)
root cause
javax.servlet.jsp.JspException: Cannot find ActionMappings or ActionFormBeans collection
org.apache.struts.taglib.html.FormTag.lookup(FormTag.java:711)
org.apache.struts.taglib.html.FormTag.doStartTag(FormTag.java:419)
org.apache.jsp.Site1_jsp._jspx_meth_html_form_0(Site1_jsp.java:115)
org.apache.jsp.Site1_jsp._jspService(Site1_jsp.java:89)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
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:810)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.
So please help me to populate Drop down box in my JSP page