• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirecting on the same url

 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have this confusion regarding PRG pattern.

When a userl clicks on a url, say "someUrl", it goes on the servlet that forwards to the jsp.

This JSP that has an HTML Table that displays list of user transaction and populate the table using JSTL c:forEach.

Below that Table are form objects made up of html text boxes, options and text area that
constitute the transaction.

Now, my confusion starts here. When I submit this form and it goes to my servlet, the user
wants the transaction to be inserted to DB but at the same time redirect to the same JSP
and populate the html table accordingly.

Can I issue a redirect on the same url?
say,




I usually redirect on a different url that forwards to another jsp after a post method.
But they want the same view to be displayed.

Will this be okay?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can give the url . Redirect makes the new request and response
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
378
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
Yes, but consider if there is a clearer way of doing this. For example, have a different URL that goes to the same jsp. Maybe /view and /insert. I think it would be confusing for the maintainer to have the same URL doing two different things.
 
Mark Reyes
Ranch Hand
Posts: 426
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jeane/Seetharaman,

Thanks for the advise and providing another way of thinking. I will try it out.

Kudos to both of you...

I think it would be confusing for the maintainer to have the same URL doing two different things.


..and by the way, I am both the creator and the maintainer here..
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mark reyes wrote:Kudos to both of you...


Welcome
mark reyes wrote:
..and by the way, I am both the creator and the maintainer here..


what about tomorrow ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic