Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Struts html tags are not working

Tags:

struts-1

I just tried to include a textbox in jsp page with struts provided tags. But it's behaving every typical.

Working

<html:text property="name" value=""></html:text>

Not Working

<html:text property="name"></html:text>
So, with out property 'value', its not working. Please help me guys.

Note: Using tomcat 6.0
bean, logics are working good and in html also most of them are working. radio, textarea, text are some which are causing issues.
JSP FILE

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Registration Form</title>
</head>
<body>
<html:text property="name"></html:text>
</body>
</html>

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this request.

exception 

org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 14

11: <title>Registration Form</title>
12: </head>
13: <body>
14: <html:text property="name"></html:text>
15: </body>
16: </html>


Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.ServletException: javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:79)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause 

javax.servlet.jsp.JspException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
    org.apache.struts.taglib.TagUtils.lookup(TagUtils.java:864)
    org.apache.struts.taglib.html.BaseFieldTag.prepareValue(BaseFieldTag.java:126)
    org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
    org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:80)
    org.apache.jsp.index_jsp._jspx_meth_html_005ftext_005f0(index_jsp.java:96)
    org.apache.jsp.index_jsp._jspService(index_jsp.java:69)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.


--------------------------------------------------------------------------------

Apache Tomcat/6.0.18
like image 632
Ramis Avatar asked Dec 29 '12 16:12

Ramis


2 Answers

The <html:text> tag is supposed to be enclosed inside an <html:form> tag, which defines the action, and thus the ActionForm instance from which <html:text> gets its value.

like image 130
JB Nizet Avatar answered Nov 02 '22 20:11

JB Nizet


Well This <Html:text> is the one kind of User input text which will get value form the userside and that will be assign further but value wont work in this tag.

that is suppose to be in the <html:form> because of that will have instance of action and that way action will be called. you can assign that a hidden variable value.

so the structure will be

<html:form>
    <html:text/>
</html:form>
like image 37
Kishan Bheemajiyani Avatar answered Nov 02 '22 19:11

Kishan Bheemajiyani