Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not able to run html:text tag of struts tld

 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends,
Here is my problem.

Search.jsp
<%@ taglib uri="/WEB-INF/tlds/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/tlds/struts-bean.tld" prefix="bean"%>
<html>
<head><title>My Human resources portal - Employee search</title></head>
<body>
My human resources portal - employee search
<hr>
<%--<html:form action="/search"> --%>
<table>
<tr>
<td align="right"><bean:message key="label.searchJsp.firstName"/>:</td>
<td><input type="text" name="firstName"></td><%-- this tag is working fine but when I replace this tag with the one written below I am not able to run my code --%>
<%--<td><html:text property="firstName"/></td> --%>
</tr>

<tr>
<td><html:submit/></td>
</tr>
<%--</html:form>--%>
</table>
</body>
</html>


struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">


<struts-config>

<!-- Global forward configuration - sending control to this jsp -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>

<!--<form-beans>
<form-bean name="searchForm" type="com.example.model.SearchForm"/>
</form-beans>

<action-mappings>
<action path="/search" name="searchForm" scope="request" validate="true" input="/search.jsp">
</action-mappings>
-->
<!-- Message Resources Configuration -->
<message-resources parameter="com.example.resources.ApplicationResources"/>
</struts-config>

SearchForm.java This file is compiling and working fine.
package com.example.model;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.*;

public class SearchForm extends ActionForm
{
private String firstName = null;

public void setFirstName(String firstName)
{
this.firstName = firstName;
}

public String getFirstName()
{
return firstName;
}

public void reset(ActionMapping mapping, HttpServletRequest request)
{
firstName = null;
}
}


And as usual, thanks in advance. Because of your help I am getting through these kind of problems and I need your help again.
regards.
 
h kumar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error message it's displaying on the screen...

Thanks
Hari
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the error I am getting when using <html:text property="firstName"/>.
Error is :

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

exception

javax.servlet.ServletException: Cannot find bean: "org.apache.struts.taglib.html.BEAN" in any scope
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.search_jsp._jspService(search_jsp.java:100)
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)

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:123)
org.apache.struts.taglib.html.BaseFieldTag.renderInputElement(BaseFieldTag.java:102)
org.apache.struts.taglib.html.BaseFieldTag.doStartTag(BaseFieldTag.java:80)
org.apache.jsp.search_jsp._jspx_meth_html_text_0(search_jsp.java:132)
org.apache.jsp.search_jsp._jspService(search_jsp.java:80)
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.28 logs.
 
Nigel King
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At the risk of asking an obvious question, you are removing the comments from these tags too?

 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yupp, I am removing these tags while running the application.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Struts are you using? If it's version 1.3.x, the URIs in your taglib declarations are incorrect. They should be:

and the struts-taglib-1.3.x.jar file should be in your WEB-INF/lb directory.
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks merrill,
I have made some changes as you said and I am using struts 1.3.8 version, but what changes should I do it in my web.xml(I think I have to make some changes in <taglib> and struts-config.xml. They are as follows;

web.xml (what should I write in taglib tag now)
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<servlet>
<servlet-name>hooha</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>

<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>hooha</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>

<taglib>
<taglib-uri>/WEB-INF/tlds/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-html.tld</taglib-location>
</taglib>

<taglib>
<taglib-uri>/WEB-INF/tlds/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/tlds/struts-bean.tld</taglib-location>
</taglib>

</web-app>

struts-config.xml (Does it also required some changes)my file is as follows:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.0//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_0.dtd">


<struts-config>

<!-- Global forward configuration - sending control to this jsp -->
<global-forwards>
<forward name="search" path="/search.jsp"/>
</global-forwards>

<form-beans>
<form-bean name="searchForm" type="com.example.model.SearchForm"/>
</form-beans>

<action-mappings>
<action path="/search" type="com.example.controller.SearchAction" name="searchForm" scope="request" validate="true" input="/search.jsp">
</action-mappings>

<!-- Message Resources Configuration -->
<message-resources parameter="com.example.resources.ApplicationResources"/>

</struts-config>


And Merrill, all *.java files are compiled and placed in their respective folders. I need your help again to get out of this bug. I am finding very hard to get over this struts. Although, I am not bad either at jsps and servlets, but I am finding very hard to get over struts. Could you guide me how should I approach over the struts so that I face least problems. Thanks again for your help.
regards.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your web.xml file looks OK, except that you need to remove all taglib references.

Are you still getting the same error? If not, please show us the error you're now getting.

In my experience, the best way to begin a struts project is to unzip the struts-blank-1.3.8.war file that comes with the download and use that as the basis for your project. This has all the artifacts you need and templates of the config files. Then just modify the templates to suit your needs.

Another suggestion would be to do a tutorial before jumping into writing your own application. You'll find some good tutorials listed in the Struts wiki.
 
anthony ryan
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Merrill,
Now I am getting this error.
I have made all the changes you have said. And removed all taglibs.
Type Exception report

message

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

exception

org.apache.jasper.JasperException: Module 'null' not found.
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: Module 'null' not found.
org.apache.struts.taglib.TagUtils.getModuleConfig(TagUtils.java:755)
org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:364)
org.apache.struts.taglib.TagUtils.computeURLWithCharEncoding(TagUtils.java:285)
org.apache.struts.taglib.html.LinkTag.calculateURL(LinkTag.java:445)
org.apache.struts.taglib.html.LinkTag.doEndTag(LinkTag.java:353)
org.apache.jsp.index_jsp._jspx_meth_html_link_0(index_jsp.java:104)
org.apache.jsp.index_jsp._jspService(index_jsp.java:62)
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.28 logs.
Apache Tomcat/5.0.28
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This error is explained in greater detail in question 11 of this forum's FAQ. The real error will be discovered by looking at your System Out log for the period of time when the server is first starting up. The most common problem is an error in parsing the struts-config.xml file due to malformed XML.

I can see one problem immediately: You've declared the wrong DTD in your struts-config.xml file. (version 1.0 instead of 1.3) My suggestion is to unzip the struts-blank-1.3.8.war file that came with the download and use the struts-config.xml file it contains rather than yours. Then just cut and paste your form bean and action mappings into the file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic