facebook

Web project directory structure – jsp folder

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #251681 Reply

    I’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.

    #251699 Reply

    Riyad Kalla
    Member

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

    #251764 Reply

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

    #251767 Reply

    Riyad Kalla
    Member

    you 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.

    #251781 Reply

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

    #251784 Reply

    Riyad Kalla
    Member

    Yes, 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.

Viewing 6 posts - 1 through 6 (of 6 total)
Reply To: Web project directory structure – jsp folder

You must be logged in to post in the forum log in