• 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

path after forward

 
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have normal adress which works, like


localhost/contextPath/foo


in url rewrite filter I forward that call like



And it gets there. On that page (foo1.jsp) I have link to original href


<a href="localhost/contextPath/foo">click.</a>


When I click that, in url rewrite filter I get:



which is bad address. How to handle that and why it happens ?
 
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miran Cvenkel wrote:


Page relative paths are a Bad Idea. Please read TypesOfPaths and RelativeLinks and correct that. If that doesn't fix the problem, post the code of your filter.
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm, did absolute path, but there is not much difference.

currently filter code:


//forwards to absolute path, and it gets where it is expected to go
((HttpServletRequest) req).getRequestDispatcher(req.getServerName() + ((HttpServletRequest)req).getContextPath() +"/jsp/custom_customer_pages/foo.jsp").forward(req, res);
return;



If I look at html with firebug I see:



<a href="localhost/contextPath/foo">Click.</a>



if I do left click, copy link location:


http://localhost/contextPath/jsp/custom_customer_pages/localhost/contextPath/foo


Real path somehow partly revealed !? Should not the purpose of forward be, to hide real path from browser ?


the


http://localhost/contextPath/jsp/custom_customer_pages/foo.jsp


is actual jsp file location

How do you explain that ?

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miran Cvenkel wrote:If I look at html with firebug I see:



<a href="localhost/contextPath/foo">Click.</a>



That is incorrect. Have you read the recommended articles on paths? The path should start with context path.


How do you explain that ?


I would recommend a less confrontational approach.
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

recommended articles on paths


Where are those ?


Thanks. It is working now.
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miran Cvenkel wrote:

recommended articles on paths


Where are those ?



J. Kevin Robbins posted two links about paths above.
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Misslooked that.

Thanks.
 
Miran Cvenkel
Ranch Hand
Posts: 245
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To partly quote myself:


Real path revealed.



This comes from:


<form method="post" action="<%=contextPath%>/jsp/c.jsp" />
<!--needs to have action as the thing would not point back to itself without action, as browser thinks it is somewhere else as the thing was forwarded-->



So in short:
1. path a , urlrewrite to path b, forward to b
2. on b path there is c.jsp with <form method="post" which needs to point back to itself with action

How to do that without revealing real path of c.jsp, that is, preserve 'a' path in browser address bar ?
 
J. Kevin Robbins
Bartender
Posts: 1810
28
jQuery Netbeans IDE Eclipse IDE Firefox Browser MySQL Database Chrome Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Miran Cvenkel wrote:
2. on b path there is c.jsp with <form method="post" which needs to point back to itself with action


Jsp's should not post to themselves or to another jsp. They should send the request to a servlet. There should never be any processing in a jsp. In fact, the jsp's should be in a folder under WEB-INF where it's impossible for the browser to reach them without going through a servlet. When you do it this way, the paths to your jsp files will never be revealed in the address bar, only the name of the servlet will be displayed.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
J. Kevin is right on the money. Please read this article for details.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic