aspose file tools*
The moose likes Servlets and the fly likes forwarding to servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "forwarding to servlet" Watch "forwarding to servlet" New topic
Author

forwarding to servlet

cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77
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

Joined: Oct 23, 2005
Posts: 3716
    
    5

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.


My Blog: Down Home Country Coding with Scott Selikoff
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
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


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77
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

Joined: Jan 10, 2002
Posts: 61658
    
  67

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?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
cathymala louis
Ranch Hand

Joined: Nov 02, 2005
Posts: 77
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

Joined: Oct 11, 2004
Posts: 3830
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

Joined: Jul 14, 2006
Posts: 1
it will work fine with above file
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: forwarding to servlet