wood burning stoves*
The moose likes Struts and the fly likes html:html causing problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "html:html causing problems" Watch "html:html causing problems" New topic
Author

html:html causing problems

Jamie Jackson
Ranch Hand

Joined: Jan 11, 2005
Posts: 58
I have very little clue what I'm doing with Struts, so I'm incrementally trying to get new things working.

Currently, I'm trying to make some use of the HTML taglib, but <html:html> is causing errors.

Here's the form (from www.bachansoft.com/tutorials/web/strutsquickstart.jsp). The file works as follows, but if I uncomment the <html:html> tags, I get the error (I'll include it after my sig).

<jsp:useBean id="name" scope="request" class="java.lang.String" type="java.lang.String"/>
<jsp:useBean id="greetings" scope="request" class="java.lang.String" type="java.lang.String"/>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%
//String name = (String)request.getAttribute("name");
//String greetings = (String)request.getAttribute("greetings");
%>
<%-- <html:html> --%>

<HEAD>
<TITLE> Hello <%=name%> - <%=greetings%> </TITLE>
</HEAD>

<BODY>
Hello <STRONG><%=name%></STRONG> - <%=greetings%>. You are now flying.
<BR><BR>
<FORM METHOD=GET ACTION="Greetings.do">
Give me your name, and I will make you fly :
<BR><INPUT TYPE="text" NAME="name">     <INPUT TYPE="submit" VALUE="Fly">
<BR><BR>
</FORM>
<html:form action="/Greetings">
<html:text property="name"/>
    <html:submit>Fly</html:submit>
</html:form>
</BODY>

<%-- </html:html> --%>

I have no clue how to debug this... any ideas?

Thanks,
Jamie

ERROR:
java.lang.NoClassDefFoundError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:141)
at jrun__greetings2ejspe.class$(jrun__greetings2ejspe.java)
at jrun__greetings2ejspe._jspService(jrun__greetings2ejspe.java:96)
...etc.
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Why do you need html:html?
[ January 11, 2005: Message edited by: Marc Peabody ]

A good workman is known by his tools.
Jamie Jackson
Ranch Hand

Joined: Jan 11, 2005
Posts: 58
I don't need it currently (AFAIK), since I think html:html does mostly i18n, which I don't need for this project. However, for my own edification, I'd like to know why it doesn't work. Also, I'm curious as to whether its use is considered best practice.

Any feedback would be appreciated, as I know squat.

Thanks,
Jamie
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

If it's not needed, it's good practice to not use it (unless you are allowing for future functionality).

There is probably something missing from your struts jar file and my guess is it's HtmlTag.java. That is the class responsible for rendering html:html.
Jamie Jackson
Ranch Hand

Joined: Jan 11, 2005
Posts: 58
Okay, I'll leave it out.

FYI, that class *is* in the jar, though, so it's still a mystery why it won't work.

Thanks,
Jamie
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Usually such an exception prints the name of the class it cannot find. It surprises me that it did not do it.

The missing class might be from something HtmlTag uses:
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.struts.Globals;
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;

I have seen where people were missing MessageResources before.
Jamie Jackson
Ranch Hand

Joined: Jan 11, 2005
Posts: 58
I went to reproduce the error, so I could see if there was such a missing dependency noted; however, html:html now magically works. Go figure. :-/

Thanks for the follow-through, Marc.

Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: html:html causing problems
 
Similar Threads
Frustration with struts. Please help!!!
Cannot retrieve mapping for action
Cannot find ActionMappings or ActionFormBeans collection
Cannot retrieve definition for form bean RegisterationForm on action /ShowWelcomePage
Locale problem in struts 1.1