• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts: Can we have a html:text tag without a html:form tag outside it.

 
Amith Mahalingaiah
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,

i just wanted to know whether we can have a <html:text> tag without a <html:form> tag.

for example
Index.jsp

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>

<html:text property="uid"/>
<html:text property="uid"/>
<html:submit property="submit"/>

</html:html>
--------------------------------------------------------------------------
web.xml

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

---------------------------------------------------------------------------
struts-config.xml

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

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


<struts-config>

</struts-config>
----------------------------------------------------------------------------

when i run the index.jsp without the <html:form> tag, it gives me an error

org.apache.jasper.JasperException: Cannot find bean org.apache.struts.taglib.html.BEAN in any scope


to counter this exception i modified my jsp to

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>

<html:html>
<html:form action="">
<html:text property="uid"/>
<html:text property="uid"/>
<html:submit property="submit"/>
</html:form>
</html:html>

..........now i get an error

org.apache.jasper.JasperException: Cannot find ActionMappings or ActionFormBeans collection

....i understand what the error means. But is there any way to just view a jsp page using the <html> tags provided by struts without using any forms, formbeans, and Action.

i just want to use the taglib <html> which struts provide.

If the answer is that i cannot use <html:text> without a <html:form> outside it....why is it so?

-Amith
 
Junilu Lacar
Bartender
Pie
Posts: 7796
62
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Amith Mahalingaiah:
If the answer is that i cannot use <html:text> without a <html:form> outside it....why is it so?
-Amith


As far as I can tell from what the Struts documentation says, you can't use the text tag outside a form tag. I suspect it has to do with the text tag using the enclosing form's associated ActionForm bean by default as the source of property values used to pre-populate the input field.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the <form> tag around the struts tag? If not, the HTML being generated is invalid.

A workaround I use is to reate an <html:form> with some action and use javascript to prevent it from submitting. And of course a comment to explain what I am doing!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic