Send redirect to relative path in JSP?

前端 未结 3 1623
后悔当初
后悔当初 2020-12-06 02:58
response.sendRedirect(\"../seja/izpisknjig.jsp\");

the file in which I execute this line is index.jsp. the directory structure looks like this.

相关标签:
3条回答
  • 2020-12-06 03:01

    You can use JSP taglib to do redirection.

    Content of index.jsp file :

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

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

    Content of index.jsp file :

    <jsp:forward page="/seja/izpisknjig.jsp" />
    
    0 讨论(0)
  • 2020-12-06 03:06

    Most reliable would be to create a domain-relative URL with the context path included.

    response.sendRedirect(request.getContextPath() + "/seja/izpisknjig.jsp");
    
    0 讨论(0)
  • 2020-12-06 03:15

    You may be overthinking this. You could just pier some generate some javascript to redirect anywhere you like.

      document.location = "MyPage.php?action=DoThis";
    
    0 讨论(0)
提交回复
热议问题