aspose file tools*
The moose likes Servlets and the fly likes Problem in request forwarding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Problem in request forwarding" Watch "Problem in request forwarding" New topic
Author

Problem in request forwarding

Hrishikesh Maha
Greenhorn

Joined: Dec 16, 2001
Posts: 9
Hi,
Iam using MVC architecture for an web application.
From an JSP file(test.jsp) I want to redirect to a bookmark in another JSP(test1.jsp) file.
Iam using the following code:
<a href="javascript://" click="javascript:return submitForm('redirect','/test/test1.jsp#12')">12</A>
The javascript submits the form to the controller servlet.
The controller servlet forwards the request to the page.
The problem in my case is the controller servlet does not forward the request to the JSP file and I see only a blank page.
I think the problem is coming due to the bookmark ("#") character.
Is there any way to solve the problem.
Thanks in advance,
Regards,
Hrish
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Hrish
What does the code in your javascript function submitForm look like?
Another thing to try is:
If all you're getting is a blank page there might be errors that are occuring that you aren't seeing. Check the localhost Tomcat log to see if thereare any errors gettng reported there. You can also put in some logging astatements to see exactley how far in your code you get before you get the blank page.


Dave
Hrishikesh Maha
Greenhorn

Joined: Dec 16, 2001
Posts: 9
Dave,
In the javascript function Iam just submitting the form.

I tried to put debug statements in the the servlet. But the code executes till the line where I forward the request to the URL which has bookmark (#).
After that Iam seeing a blank page.
But if I remove the # character from the URL then the request gets forwarded properly to the page.
Regards,
Hrish
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12675
    
    5
I seem to recall hearing that certain browsers have this problem, so it may not be your code at all.
Bill
Axel Janssen
Ranch Hand

Joined: Jan 08, 2001
Posts: 2164
Cant you just strip the "#12" part of the url in the controller servlet?
So before creating the RequestDispatcher you only have "/test/test1.jsp" ?
Hrishikesh Maha
Greenhorn

Joined: Dec 16, 2001
Posts: 9
Hi Axel,
I want to forwarded to the page with the bookmark so that when the page loads it directly goes to the book mark.
What you have suggested no doubt works without the bookmark character but my application requires it to forward with a bookmark
Regards,
Hrish
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Here is an ugly little hack I coded up, which seems to work in IE5.5 under Tomcat 4.0.1

You would need to change your requests from 'mypage.jsp#2' to 'mypage.jsp?a=2', and then use javascript to move the page...

Note the line:
window.location = "Test.jsp?a=<%= anchor %>#<%= anchor %>";

This is the ugly little hack part.

You will request:
http://localhost:8080/examples/Test.jsp?a=7
And the browser bar will display:
http://localhost:8080/examples/Test.jsp?a=7#7

Take out the "?a=<%= anchor %>" in the window.location line above, and uncomment the System.out.println from the JSP code to convince yourself why we need this.
Hrishikesh Maha
Greenhorn

Joined: Dec 16, 2001
Posts: 9
Hi Mike,
Thanks....this seems to work.
Regards,
Hrish
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in request forwarding
 
Similar Threads
facing problem with "redirect" in Tiles
Struts bookmark question
File Upload using commons-fileupload-1.0
Redirect when Javascript is disabled
how to tell MultiActionController Command Object is Of type com.dss.ems.model.User