• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

URL-Rewriting does not work

 
Ranch Hand
Posts: 109
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic