Can we redirect one jsp page to another jsp page

I want to open the jsp page without accessing my servlet code. those. I do not need to enter my url in (action = "url") my jsp code and not have access to my Servlete code.

<form id="main" method="post" name="main" action="dpRegPost" onsubmit="return validate();">

Can someone help me with this?

+4
source share
6 answers

Try the following:

<form id="main" method="post" name="main" action="" onsubmit="redirect(this);">
    <input type="submit" name="submit"/> 
</form>


function redirect(elem){
     elem.setAttribute("action","somepage.jsp");
     elem.submit();
}
+2
source

You can also try this.

<jsp:forward page = "abc.jsp" />
+5
source

javascript jsp

<script type="text/javascript">
window.location.href = "www.google.com";
</script>

jsp

<%

    response.sendRedirect("www.google.com");
%>
+4

jstl taglibrary jsp. ,

 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>  

jsp

<c:redirect url="/xxx.jsp"/>
+3

:

<jsp:redirect page="xyz.jsp" />
+1
use the following code to redirect on another page in js...

$('#abc_id').click(function() {
            updateSubContent("abc.jsp");
        });
0

Source: https://habr.com/ru/post/1539571/


All Articles