java - JSP validate user is coming from previous page -


In my JSP webpad, I want to verify that a user is coming from a specific page, Http: //myapplication.com/foo.jsp . To check on the page, I could:

  string ref = request.getHeader ("Referrer");   

then ref to http://myapplication.com/foo.jsp

Compare what are some other techniques to verify that this verification can be easily deceived, that a client is coming from the expected URL?

I think it has come before the SO. Earlier, JSP preprocessing servlets generate a unique token. Thanks

PR

String token = UUID.randomUUID (). ToString ();

Store it in session

  session.setAttribute ("token", token);   

Give it hidden input value of the form

  & lt; Input type = "hidden" name = "token" value = "$ {token}" />   

Or as the request parameter of the link when you are using the link instead of the form

    

Compare the preprocessing servlet of another JSP to one of the sessions

  string token = (string) session.getAttribute ("token" ); Session.removeAttribute ("token"); If (token! = Null & token.quals (request.getParameter ("token")) {// valid, it is necessary to continue} Else {// invalid, block request}   

This was the original concept that considers a page-to-page conversation. You want to use multiple browser pages / tabs that you can use to set & lt; String & gt; or Maps & lt; String, set & lt; String & gt; & Gt; Instead of tokens (as keys and tokens value as URIs), instead of .

Comments