File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes confused on how to use struts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "confused on how to use struts" Watch "confused on how to use struts" New topic
Author

confused on how to use struts

Keav Julian
Greenhorn

Joined: Jul 09, 2002
Posts: 11
Hi All. I am new to struts and very confused. First question, what is the difference between struts-conf.xml and struts.ltd files? I am trying to redirect adding the following definition to my tld file and tried to use <html:redirect href='<%=url%>'/> but it doesnt redirect:

<tag>
<name>redirect</name>
<tagclass>org.apache.struts.taglib.RedirectTag</tagclass>
<bodycontent>empty</bodycontent>
<attribute>
<name>id</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>pageContext</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>parent</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
<attribute>
<name>href</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
</tag>

Do I need to add something to my .xml file too to be able to use this tag? Does anyone have any suggestions? Thank you in advance.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
It is not necessary to modify any of the .tld files or the struts-config.xml in order to perform a redirect. I'd suggest you undo any changes you've made and simply specify the following in your JSP.

If you're using Struts 1.3.5 use this:

If you're using an earlier version of Stuts, use this:


Merrill
Consultant, Sima Solutions
Keav Julian
Greenhorn

Joined: Jul 09, 2002
Posts: 11
Thank you so much for your reply. But I still get a blank page when I do <logic:redirect href='<%=noCookieURL%>'/>
I know the url works because I can type the url manually in the browser.

You have any idea why my page would come up blank? Thanks for looking into this for me.
Keav Julian
Greenhorn

Joined: Jul 09, 2002
Posts: 11
BTW, I am using the older version of Strut so I did as you suggested:

<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Are you using a relative URI, or a full URI (starting with http://)? If it's relative, perhaps you haven't specified it correctly.

Incidentally, if you're using a relative URI, it's better to use page="" than href="" page will allow you to specify a URI realtive to the context root. Example: The tag

redirects to http://myserver.com/myWebContext/mypage.jsp

Another thing to check: Make sure that the file struts-logic.tld actually does exist in your application's WEB-INF directory.
Keav Julian
Greenhorn

Joined: Jul 09, 2002
Posts: 11
I am using a full URI. And I do have struts-logic.ltd in my xml folder.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Originally posted by Keav Julian:
I do have struts-logic.ltd in my xml folder.

It needs to be in WEB-INF, not xml.
Keav Julian
Greenhorn

Joined: Jul 09, 2002
Posts: 11
Sorry. It is in WEB-INF folder.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
First, try substituting the scriptlet with a literal such as "http://www.yahoo.com" that you know should work. If that works, you know there's a problem with your scriptlet variable. If it still doesn't work, you may have to take more drastic measures.

It's possible that in your attempts to modify the TLDs that you messed something up. I'd suggest saving your current project to a separate directory, then starting fresh by unzipping the struts-blank.war file and making that your working directory. Then add back your JSPs, classes, etc. Don't replace the web.xml file or the struts-config.xml file. Just cut and paste your Form bean definitions and Action mappings from the old file into the new. Then restart the server and see if it works.
[ February 14, 2007: Message edited by: Merrill Higginson ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: confused on how to use struts