• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URL-Rewriting does not work

 
Oliver Rensen
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ranchers,

URL-rewriting is not so easy as it is described in the books.

My web-app contains the following flow:

Browser => index.jsp => prodSelectData.jsp
=> FrontController.java => prodList.jsp

I have rewrited all my URLs with <c:url value="...">.

index.jsp:

<img src='<c:url value="/header.jpg" />'>

<a href="<c:url value='/prodSelectData.jsp' />">...</a>

prodSelectData.jsp:

<a href="<c:url value='/index.jsp' />">
Back to the main-page</a>

<form method="post"
action='<c:url value="reports/viewProdList" />'>

The problem is, that only the URLs within the index.jsp are containing a jsessionid:

<img
src='/Reports/header.jpg;jsessionid=6055FA09B7ABDF6E043D50D318934C40'>

<a href="/Reports/prodSelectData.jsp;jsessionid=6055FA09B7ABDF6E043D50D318934C40">...</a>

In the prodSelectData.jsp there are no jsessionids:

<a href="/Reports/index.jsp">
Back to the main-page</a>

<form method="post" action='reports/viewProdList'>

Something must be wrong in my JSPs. The jsessionid is lost between index.jsp and prodSelectData.jsp, but why?
Both JSPs contain the page-directive session="true".

Kind regards
Oliver
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think you are losing your session.

The container will attach the jsessionid the first time you access the site because it doesn't know whether or not you have cookies enabled. On the second request it will know that you have cookies enabled and it doesn't need to append the jsessionid to every url anymore.

If you disable cookies on your browser you should see the jsessionid in every request.
 
Oliver Rensen
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Marc, thank you for the quick help.
What you have said is correct, my URL-rewriting works.

And I must change my opinion:
URL-rewriting IS as easy as it is described in the books.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic