wood burning stoves 2.0*
The moose likes Struts and the fly likes [solved] problem writing href Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "[solved] problem writing href" Watch "[solved] problem writing href" New topic
Author

[solved] problem writing href

Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
Got a weird problem: i use <a href="jsp/main.jsp"> from jsp\main.jsp which goes http://localhost:8080/appname/jsp/main.jsp (which is right), but then i lose sight of css files (which are in \css), and if i push the link again it goes http://localhost:8080/appname/jsp/jsp/main.jsp , how do i write the href properly?

P.S. this is part of a struts 2 app with this mapping:


EDIT1: seems that one solution was: <a href="mainAction.action">
Are there any other solutions?
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9291
    
  17

Don't use relative URLs in your tags. use absolute URLs i.e. starting from /contextPath. You can add the context path to your URLs using either c:url JSTL tag or using ${pageContext.request.contextPath} EL before the actual URL...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Tudor Raneti
Ranch Hand

Joined: Nov 29, 2009
Posts: 145
Thanks. There is a second problem with relative paths, that if i prepend with / or ../ the appName gets cut from the URL. But i learnt my lesson, i will use struts 2s tags for it, especially since it seems to do some url rewriting as well.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [solved] problem writing href
 
Similar Threads
[solved] struts 2 mapping for .action
http://localhost:8080 not working,giving IP works fine!
[solved] passing 3 times by default through action using struts 2
Use welcome-file-list to run struts action?
Servelt url should not be displayed.