• Post Reply Bookmark Topic Watch Topic
  • New Topic

post back page  RSS feed

 
mark babcock
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way in JSP to tell if a page is a post back or not?
for example if I have a form and it submits to itself. Is there a way in jsp to determine if its the first time the page has come up or if it is from pushing the submit button?
 
Phil Chuang
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could set a variable in the session and check to see if it exists, or you could set a hidden field in the form and then check it in the request obj.
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the methods Phil mentions are excellent -- and probably the most popular. You can also use HttpServletRequest.getHeader() and get the referer -- that will tell you which page the user came from. You can see if they came from this same page.
 
Praful Thakare
Ranch Hand
Posts: 643
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark
u can try this as well,
if u have a submit button with name say btnSubmit
then at very bigning or ur jsp u can check
if(request.getParameter("btnSubmit")==null)
{
this means submit button is not clicked
and still ur here..!!!
}
regards
Praful
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!