开发者

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:

  1. 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.

  2. 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.

  3. Use a hidden field in each form that will uniquely identify it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜