0

I have a hyperlink for one of the column which looks like this.

<td align="ct"><a href="<%=getContext()%>/otp/taxView.do?call=first&taxId=<bean:write name="otping" property="taxNumber" />"><bean:write name="otping"
                                property="taxNumber" /></a>
                        </td>

Can I use the same to redirect to a different uri? When I google for redirect there are options to move action to controller and use sendRedirect and meta-refresh. Will the above work? or should I use a different method?

Geek
  • 3,187
  • 15
  • 70
  • 115
  • 1
    What would you like to achieve? This code just produces a uri, you can produce different uri, but none of them will redirect automatically browser to different page. However when you click the link, you will go to desired page. – Gas Jul 29 '14 at 22:17
  • 1
    What you're using is a link that the user must click on. Redirect means that the address is changed without the user having to click anything. So its not clear what you're asking. – developerwjk Jul 29 '14 at 22:21
  • @Gas and @ developerwjk.. Thanks for your replies. My requirement is that when I click the link to should be redirected to a different uri. RightNow its /otp/taxView.do? and I would want to change them to /taxFilings/Annuity.do? or something like that. But the customer used the word redirect to a different uri. But what I infer from your replies is redirect happens automatically without the user needing to click a button. But my requirement is on a hyperlink click. So im assuming that a href would itself take me to a different uri. Correct me if im wrong. – Geek Jul 30 '14 at 12:51
  • Do you mean you want to do the redirect after the link. User clicks link to taxView.do, and inside taxView.do there's a `response.sendRedirect("Annuity.do");` so there's both a click and a redirect? – developerwjk Jul 30 '14 at 20:13

2 Answers2

0
$(document).ready(function(){
    $("a").click(function(e){
    e.preventDefault();
    window.location.href = 'Different uri'
    });
});

Hope it helps.

Leo
  • 5,017
  • 6
  • 32
  • 55
0

This is referred as post-redirect-get pattern. You send POST to one uri, it performs action and then returns 'redirect' to the browser, which presents result page. This prevents re-posting when user is going through back/forward in history. This requires using respnse.sendRedirect(), as it looks like using Struts it can be defined via configuration.

Check here for more details:

post-redirect-get-prg-pattern-in-servlet-jsp
post-redirect-get-when-passing-data-to-the-form
Implement-Post-Redirect-Struts

Community
  • 1
  • 1
Gas
  • 17,601
  • 4
  • 46
  • 93