• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

confused on how to use struts

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
 
Keav Julian
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using a full URI. And I do have struts-logic.ltd in my xml folder.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry. It is in WEB-INF folder.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic