Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reveal / know / get the sending page using request or session in servlet

I have jsp page (say, source.jsp) with form:

<html>
<head>
<body>
    <form action="Servlet123" method="POST">
        // form fileds ... 
    </form>
</body>
</head>
</html>

And the required doPost in servlet -

@WebServlet("/Servlet123")
public class Servlet123 extends HttpServlet {
    protected void doPost(HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {

          //use with requset...
    }
}

How can I get the page (in this case - source.jsp) sending the request to this servlet? Is there a method in request/session?

like image 672
URL87 Avatar asked Aug 06 '12 14:08

URL87


1 Answers

Use passing parameter in a request through a hidden field:

In your jsp page:

<form action="Servlet123" method="post">        
   <input type="hidden" name="namePage" value="sourcePage" />
</form>

In your servlet:

String namePage = request.getParameter("namePage");
like image 197
kapandron Avatar answered Oct 23 '22 10:10

kapandron