Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

forwarding to servlet

 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am using this code to forward the page to the PDFDisplay servlet, because I want to display a byte[] array of images in PDFDisplay page.

RequestDispatcher rd = request.getRequestDispatcher("PDFDisplay");
rd.forward(request,response);

The code in PDFDisplay is working and displaying the image which I want to display. But the image is displayed in the old page. The url is not changing in the webbrower. What should I do to change the url to point to this servlet page. Any pointer would be greatly appreciated.

Thanks.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4007
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the PDFDisplay servlet? This sounds like some proprietary (unless my memory is foggy) and should probably be asked to the manufacturers of the servlet.
 
Naseem Khan
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since the forwarding is done by web server, so client does not know about this forwarding. Thats why browser url will not change with forward. But still the servlet container will execute the service method of PDFDisplay Servlet.

Naseem
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

PDFDisplay.java is the servlet name.

Is there is any way to change the url while forwarding.

Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64613
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by cathymala louis:

Is there is any way to change the url while forwarding.


No. That's the whole point of a forward, that it executes within the context of a single request.

Why is what is showing in the URL bar of the browser an issue?
 
cathymala louis
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because I want to go to the previous page by clicking back button. To choose a different image id. Is there is any other way to approach this problem.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by cathymala louis:
Hi

PDFDisplay.java is the servlet name.

Is there is any way to change the url while forwarding.

Thanks.


Well, sendRedirect() works like you wish.

So, make an entry in web.xml like this:



Now, write this code where you are forwarding currently:



You can also change extension (pdf to java or anything) at both the place.

 
chandrashekar naidu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will work fine with above file
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic