How to identify the JSP page that sent the request?
I've searched all over the internet for an answer but i found none. I have a Servlet (the controller ) that's processing two forms from two different JSP pages. Is it possible to know the page that sent the request to the Servlet ? Anythi开发者_运维知识库ng that could identify that particular JSP page ? I tried to get the URI,but no success so far.
Thanks a lot.
I can think of a few different ways to do this:
Use the
Referer
header. However, while this is the simplest way to identify the source of a request, it's probably the least dependable since the referer field can be easily spoofed and may not even be sent by the user-agent.Have the two forms submit to two slightly different URL patterns both of which map to the controller servlet in question which would allow it to differentiate between the two.
Use a hidden field in each form that will uniquely identify it.
精彩评论