Discussions

Web tier: servlets, JSP, Web frameworks: absolute path versus relative path in JSP

  1. absolute path versus relative path in JSP (2 messages)

    I have an index.jsp that will forward to different JSP pages
    based on different conditions:

    <%
    if (cond1)
    {
    %>
    <jsp:forward page="address/page1.jsp"/>
    <% }
    else if (cond2)
    {
    %>
    <jsp:forward page="address/page2.jsp"/>
    <% }
    else
    {
    %>
    <jsp:forward page="address/page3.jsp"/>
    <% }
    %>


    The problem is in different pageX.jsp, when user submit form data, it will go to
    other pages. Before, the index.jsp is in the same directory as pageX.jsp.
    But now I moved out ofthe address folder, and it has broken links.

    In my case, should I specify the abosolute path, rather than relative path?
    so that in whatever situation, it will work.

    please help. thanks!!
  2. I think absolute path should work for you. Implementing the controller logic in JSP may not be a good idea. If possible use some MVC framework like struts. Struts is very flexible to implement controlling logic.


    Hope this helps,
    Senthil.
  3. I have an index.jsp that will forward to different JSP pagesbased on different conditions:<% if (cond1) {%> <jsp:forward page="address/page1.jsp"/><% } else if (cond2) {%> <jsp:forward page="address/page2.jsp"/><% } else {%> <jsp:forward page="address/page3.jsp"/><% } %>The problem is in different pageX.jsp, when user submit form data, it will go toother pages. Before, the index.jsp is in the same directory as pageX.jsp. But now I moved out ofthe address folder, and it has broken links.In my case, should I specify the abosolute path, rather than relative path?so that in whatever situation, it will work.please help. thanks!!
    I think you answered your own question 'should I specify the abosolute path... so that in whatever situation, it will work.'

    Absolutely!