Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with redirect  RSS feed

 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have problem in redirecting a request.
Problem explanation:-
I have one jsp(submitjob.jsp) ,this jsp forward request to a servlet(submitJobHandler.java)which handles all the request send by submitJob.jsp.
Servlet will handle all the task and display a message that "you job is submited ", now I want to redirect to submitJob.jsp after showing this message by servlet (submitJobHandler.java).

plz help me with example to solve this problem.
Thanx in Advance.
 
Sravan Kumar
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the first place, do you mean the JSP submits a request to the servlet or does it forward? Do you use this JSP to receive a request?

Use RequestDispatcher for forwarding the request from a servlet to a JSP. Do you have any issues in that?
 
lexander Bosco
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
does submitjob.jsp receive the request first? if yes, submitJobHandler.java should redirect using response.sendRedirect to ur success page.

hope this helps
 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx for your reply.
As we are using this forum in it when we post any Question or we reply to any one then after post it took us to a new page and on that page it shows message "please wait we are redirecting to forum".
I want do the same in my application.
plz help ...
 
Vikas Bhatia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ahmed Shaikh:
Thanx for your reply.
As we are using this forum in it when we post any Question or we reply to any one then after post it took us to a new page and on that page it shows message "please wait we are redirecting to forum".
I want do the same in my application.
plz help ...


You can do the following [pretty sure there are cleaner ways to do this]:

when you are outputting ur message, pass it as a parameter to a JSP which will show that message, plus also will do a timer based redirect to a page that again can be passed as a parameter. Makes sense?

cheers
Vikas
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you post a reply to a thread ion the JavaRanch, it takes you to an intermediate 'thank you for posting, we are now returning you to...' page.

Post a reply, view the source when that page loads, steal the code. Pay particular attention to the part in the HTML header.

Dave.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here, I'll save you the trouble:

'3' means redirect in 3 seconds. Then have a semicolon and the link that will be redirected to.

Dave
 
Vikas Bhatia
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by David O'Meara:
Here, I'll save you the trouble:

'3' means redirect in 3 seconds. Then have a semicolon and the link that will be redirected to.

Dave


Here is some sample code, that uses 3 files: 2 JSPs and 1 servlet.

index.jsp


TestServletv1


result.jsp


HTH!!!

cheers!

Vikas
 
Ahmed Shaikh
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx a lot to All.
Now my code is working.
Thanx again.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!