Problem with Basic Struts Example

M

Mike

I'm trying to get a basic struts example to work so I can get to more
advanced coding.

The example is similar to that at beginning of the Wrox book
"Professional Jakarta Struts"

I get the error "Attribute name invalid for tag form according to TLD"
when I run the view page below.

Obviously the attribute "name" is in struts-html.tld

Anyone spot what I'm doing wrong?

Below is my view page and struts config file:


..................... view page ......................

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


<html>
<head>
<title>Wrox Struts Application</title>

<body>

<html:form action="Lookup" name="lookupForm" type="ch03.LookupForm" >

Symbol: <html:text property="symbol" /><br><br>

<html:submit /><br><br>

</html:form>


</body></html>


................ struts config ............


<?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>

<form-beans>
<form-bean name="lookupForm" type="ch03.LookupForm" />
</form-beans>

<action-mappings>
<action path="/Lookup" type="ch03.LookupAction"
name="lookupForm">
<forward name="success" path="/quote.jsp"/>
<forward name="failure" path="/index.jsp">
</action>
</action-mappings>

</struts-config>
 
S

Sudsy

Mike wrote:
I get the error "Attribute name invalid for tag form according to TLD"
when I run the view page below.
<html:form action="Lookup" name="lookupForm" type="ch03.LookupForm" >

As you should. Examine carefully the javadocs for the html tags. Check
out the list of attributes for the form tag. There is no "name"
attribute there. Fix that and it will complain about "type", since that
is not a valid attribute of the form tag either. Those attributes belong
in a difference place, namely the struts-config.xml file.
May I suggest you open a browser window and click on the following URL:
<http://struts.apache.org/userGuide/struts-html.html>
You might want to keep that browser window open anytime you're doing
JSP development with html tags; I do!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top