- This topic has 5 replies, 2 voices, and was last updated 19 years, 1 month ago by
Riyad Kalla.
-
AuthorPosts
-
Chuck MinarikMemberI’m trying to organize a project that has a lot of files. So far, I have placed all my picture files in an “images” folder, put my tlds in a “taglibs” folder, and created an include file that points to my tlds. But I haven’t figured out the correct way to put my jsp files in a separate folder. I’d like to have my main/index jsp in WebRoot, but have all the others in a “jsps” folder.
I’m testing with the StrutsLoginDemo app. I created a “jsps” folder directly under WebRoot, and moved userLoginSuccess.jsp to it, but the application can’t find it. I have tried multiple combinations that have not worked in my struts-config.xml file:
<forward name="success" path="userLoginSuccess.jsp" /> <forward name="success" path="jsps/userLoginSuccess.jsp" /> <forward name="success" path="/jsps/userLoginSuccess.jsp" /> <forward name="success" path="./jsps/userLoginSuccess.jsp" />
Then I thought maybe I needed to update my build path, but I can’t figure out how.
My general directory structure is as follows:
WebRoot |___images (not in this project) |___jsps |___META-INF |___WEB-INF |___classes (usually, but not in this project) |___lib (.jar files) |___taglibs (.tld files) |___userLogin.jsp
Would you please show me a “best practices” method of segregating jsp files? Any other suggestions regarding my directory structure would be appreciated also.
TIA.
May 6, 2006 at 8:39 am #251699
Riyad KallaMemberWhat you are trying to do is all right, and your mapping of:
<forward name=”success” path=”/jsps/userLoginSuccess.jsp” />Was the right one. What was happening is you likely weren’t restarting your app after changing the struts-config.xml file, so you kept getting a file not found error. Does this sound like it could have been the case?
May 8, 2006 at 11:41 am #251764
Chuck MinarikMemberThat must have been the problem, because it works now.
However, I have a similar situation that I can’t get to work. Trying the same technique from another jsp, I relocated Top.jsp to the jsps folder, but I get an HTTP 404 message:
<FRAMESET rows="76, 574,*" FRAMEBORDER=NO FRAMESPACING=0 BORDER=0> <FRAME src="/jsps/Top.jsp" name="top" NORESIZE> <FRAME src="Bottom.jsp" name="bottom" NORESIZE> </FRAMESET>
Any ideas?
May 8, 2006 at 12:49 pm #251767
Riyad KallaMemberyou may need to use “jsps/Top.jsp” as a relative path, I believe / in a standard HTML page will resolve to the root of your domain.
May 8, 2006 at 5:34 pm #251781
Chuck MinarikMemberThat worked…”jsps/Top.jsp”. But something else is strange. Top.jsp also refers to a couple of other jsps. If I put them in the jsps folder, I have to refer to them by name only, no path…for example: TopLeft.jsp & TopRight.jsp.
If I leave them in WebRoot, I have to refer to them as ../TopLeft.jsp & ../TopRight.jsp. It’s as if the current directory was changed.
Is this what you’d expect?
May 8, 2006 at 6:44 pm #251784
Riyad KallaMemberYes, you are forced to use relative paths. That’s normal. It’s just the difference between how the *app server* resolves paths (relative to the root of the URL) and how Struts resolves path (relative to the root of your webapp). It’s a bit confusing at first.
-
AuthorPosts