• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Problem in request forwarding

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hrishikesh Maha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I seem to recall hearing that certain browsers have this problem, so it may not be your code at all.
Bill
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,
Thanks....this seems to work.
Regards,
Hrish
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic