Java page re-direct Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Java page re-direct without wasting too much if your time.

The question is published on by Tutorial Guruji team.

What I want to do is go to a disclaimer page when they first initially hit this method, and then any time after that go to a different page. My current method just takes to me the disclaimer page. Let me know if furthur explanation is needed…thanks!!!

public int show(Action action)
throws Exception
{

    HttpServletRequest request = action.getRequest();

action.setJspURI("htemp.jsp");
return FORWARD;
}

Basically I need to add an If to go to a page the first time it hits this method I guess like so:

public int show(Action action)
throws Exception
{

    HttpServletRequest request = action.getRequest();
--->> If (FIRST TIME HITTING THE METHOD)  
          {
           go here!!!        
          }  
 action.setJspURI("htemp.jsp");
return FORWARD;
}

Answer

When the person hits the page for the first time, throw a flag on the session layer. Then anytime a person comes to the page you can check to see if it exists or not, and redirect them accordingly. Only problem with that is that they have to agree to it every time they visit unless you implement a login system.

P.S. you should be able to get the Session off of the request object you get in that first line. Then just use setAttribute on that session object.

We are here to answer your question about Java page re-direct - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji