• Post Reply Bookmark Topic Watch Topic
  • New Topic

path after forward

 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • 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 ?
 
J. Kevin Robbins
Bartender
Posts: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Mark post as helpful
  • send pies
  • 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: 202
2
  • Mark post as helpful
  • send pies
  • 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:


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


the

is actual jsp file location

How do you explain that ?

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
recommended articles on paths

Where are those ?


Thanks. It is working now.
 
Dave Tolls
Ranch Hand
Posts: 2268
23
  • Mark post as helpful
  • send pies
  • 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: 202
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Misslooked that.

Thanks.
 
Miran Cvenkel
Ranch Hand
Posts: 202
2
  • Mark post as helpful
  • send pies
  • 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: 1801
28
Chrome Eclipse IDE Firefox Browser jQuery Linux MySQL Database Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Posts: 65516
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
J. Kevin is right on the money. Please read this article for details.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!