Send redirect to relative path in JSP?

response.sendRedirect("../seja/izpisknjig.jsp");

the file in which I am executing this line is index.jsp. The directory structure is as follows.
project
--index.jsp
Seya
--izpisknjig.jsp

How to create a relative path for redirecting to izpisknjig.jsp.

+5
source share
3 answers

The most reliable would be to create a domain-related URL with the outline enabled.

response.sendRedirect(request.getContextPath() + "/seja/izpisknjig.jsp");
+17
source

You can use JSP taglib for redirection.

The contents of the index.jsp file:

<jsp:forward page="../seja/izpisknjig.jsp" />

If the project and seja are at the root of your webapp context (i.e. http: // host: port / context / project )

The contents of the index.jsp file:

<jsp:forward page="/seja/izpisknjig.jsp" />
0

You can overestimate this. You can simply attach some of them to create javascript to redirect anywhere.

  document.location = "MyPage.php?action=DoThis";
-1
source

All Articles