Html:select and Html:option problems
I got exception below and I mentioned all pages regarding this bug.
org.apache.jasper.JasperException: An exception occurred processing JSP page /jsp/dublicateId.jsp at line 46
43:
44: <tr><td>Reason For Requesting Dublicate ID:</td>
45: <td>
46: <html:select property="reason" size="2" >
47: <html:options name="lost"/>
48: <html:options name="damaged"/>
49: </html:select>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.jsp.dublicateId_jsp._jspService(dublicateId_jsp.java:174)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
root cause
javax.servlet.jsp.JspException: Cannot find bean under name org.apache.struts.taglib.html.BEAN
org.apache.struts.taglib.html.SelectTag.calculateMatchValues(SelectTag.java:240)
org.apache.struts.taglib.html.SelectTag.doStartTag(SelectTag.java:200)
org.apache.jsp.jsp.dublicateId_jsp._jspx_meth_html_005fselect_005f0(dublicateId_jsp.java:212)
org.apache.jsp.jsp.dublicateId_jsp._jspService(dublicateId_jsp.java:121)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.
my jsp page:
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ page import="com.rec.bookbank.persitencejavafile.DuplicateIdObject" %>
<%@ page import="java.util.*;"%>
<html>
<body>
<html:form action="/id" ></html:form>
<div id="container">
<div id="header">
<table width="960">
<tr>
<td id="header1" align="center">
DUBLICATE ID CARD REQUEST
</td><td><a href="/REC_BookBank/jsp/exisitingUser.jsp">Back</a></td>
</tr>
</table>
</div>
<div id="content">
<table cellpadding="10" align="center">
<tr><td>Reason For Requesting Dublicate ID:</td>
<td>
<html:select property="reason" size="2" >
<html:options name="lost"/>
<html:options name="damaged"/>
</html:select>
</td></tr>
<tr><td>Mode of Dispatch ID card :</td>
<td>
<html:select property="dispatch" size="2" >
<html:options name="courier"/>
<html:options name="manual"/>
</html:select>
</td></tr>
<tr>
<td>
Conformation Of Mailing Address:
</td>
<td>
</td>
</tr>
<tr>
<td><font size="3"id="header1">Charges Applicable</font></td>
</tr>
<tr><td>Components </td><td>Amount IN INR</td></tr>
<tr><td>Dublicate Card Charges</td><td><html:text property="cardcharges" value=""/></td>
</tr>
<tr>
<td>Courier Charges
</td><td>
</td>
</tr>
<tr>
<td>Grant Total</td><td>></td>
</tr>
<tr><td><html:submit property="submit" value="paynow" /></td><td><html:button property="" value="Later"/></td></tr>
</table>
</div>
</div>
</body>
</html>
My action page:
package com.rec.bookbank.action;
import com.rec.bookbank.form.DuplicateIdForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionForward;
import com.rec.bookbank.Constants.Constants;
import com.rec.bookbank.persitencejavafile.DuplicateIdObject;
import com.rec.bookbank.dao.DuplicateIdDAO;
import java.util.List;
import java.util.ArrayList;
public class DuplicateIdAction extends org.apache.struts.action.Action {
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
DuplicateIdForm duplicateIdForm=(DuplicateIdForm)form;
List<DuplicateIdObject> convert=new ArrayList<DuplicateIdObject>();
convert=DuplicateIdDAO.duplicateidrequest();
System.out.println("list in action::" +convert.size());
request.setAttribute("reason", convert);
System.out.print("request in Action::"+request.getAttribute("duplicate"));
return mapping.findForward(Constants.ACTION_FORWARD_SUCCESS);
}
}
My dao :
package com.rec.bookbank.dao;
import com.rec.bookbank.form.DuplicateIdForm;
import com.rec.bookbank.sessionCfg.HibernateUtil;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Query;
import com.rec.bookbank.persitencejavafile.DuplicateIdObject;
public class DuplicateIdDAO {
public static List duplicateidrequest() {
Session session=null;
try {
List duplicate = new ArrayList();
session = HibernateUtil.getSession();
System.out.println(" Session :: "+session);
Query query = session.create开发者_如何学GoSQLQuery("{call SP_Duplicate()}");
duplicate = getList(query.list());
System.out.println("in dao getduplicate----"+duplicate);
if(duplicate!=null)
return duplicate;
else
return new ArrayList();
} catch(Exception e) {
System.out.println("Exception in duplicateidrequest::"+e);
return null;
}
finally {
session.close();
}
}
public static List<DuplicateIdObject> getList ( List<Object[]>duplicate ) {
System.out.println("in convertor");
List<DuplicateIdObject>duplicateobjectlist = new ArrayList<DuplicateIdObject>();
for(Object[] array:duplicate) {
System.out.println("value in method::"+duplicate.size());
DuplicateIdObject duplicateIdObject=new DuplicateIdObject();
duplicateIdObject.setReason(array[0].toString());
duplicateIdObject.setDispatch(array[1].toString());
duplicateobjectlist.add(duplicateIdObject);
}
return duplicateobjectlist;
}
}
my persistence class:
package com.rec.bookbank.persitencejavafile;
import javax.persistence.Entity;
import javax.persistence.Id;
import java.io.Serializable;
@Entity
public class DuplicateIdObject implements Serializable
{
@Id
private int id;
private String reason;
private String dispatch;
private String address;
private String cardcharges;
private String couriercharges;
private String total;
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public String getCardcharges() {
return cardcharges;
}
public void setCardcharges(String cardcharges) {
this.cardcharges = cardcharges;
}
public String getCouriercharges() {
return couriercharges;
}
public void setCouriercharges(String couriercharges) {
this.couriercharges = couriercharges;
}
public String getDispatch() {
return dispatch;
}
public void setDispatch(String dispatch) {
this.dispatch = dispatch;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getReason() {
return reason;
}
public void setReason(String reason) {
this.reason = reason;
}
public String getTotal() {
return total;
}
public void setTotal(String total) {
this.total = total;
}
}
my hibernate:
package com.rec.bookbank.sessionCfg;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class HibernateUtil {
private static final SessionFactory sessionFactory;
private static final Session session = null;
static {
try {
sessionFactory = new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}
}
public static SessionFactory getSessionFactory() {
return sessionFactory;
}
public static Session getSession(){
return sessionFactory.openSession();
}
}
None of your form tags are actually within the form, because of this:
<html:form action="/id" ></html:form>
Also, please take some care in your code formatting: IDEs do it automatically, and it can assist in tracking down issues like this. Plus it's way, way easier for other people to look at and understand.
精彩评论