Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp:forward issue  RSS feed

 
Kathy Vance
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need your guys help here.
In order to hide the URL from users, I used jsp:forward tag and reset the value of page attribution to a session value which associated with the login info of an user. My intention was to let users only view the documents which they have privilege to view.
the code is as follows:
<%@ page language="java" import="java.util.*, java.sql.*, java.io.*, java.net.*, javax.mail.URLName" %>
<%
String uinfo=(String)session.getAttribute("empID");
String f_name="pdf/"+uinfo+".pdf";
%>
<jsp:forward page='<%=f_name%>' ></jsp:forward>
The problem I had was that forward tag did not use the name of page which dynamically set in the tag. No matter what the value of f_name is, Jrun redirected/showed the same page (document). It looked to me that it was an issue on how to load the page.
Am I miss anything here? How do I fix it? Please help.
Thanks in advance.
Kathy
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The most likely cause is the relative url you are using.
I'd construct the URL as an absolute (relative to the context) url. Something along the lines of:

assuming that the pdf folder is at the root of your web app.
 
Kathy Vance
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for your reply. I made changes. But it still shows the page whatever the first value of uinfo is. Is anything related to the page cache?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's possible. I'd print the result of fName to the log as a basic debugging technique to see if its value is what you expect whenever the page is executed.
Since ths page is active, you should be setting the headers such that caching is disabled (search forum for details).
 
Kathy Vance
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Bear.
It is a Page Cache issue. Changing the HTTP header would solve the issue. Finally, I attached a random number on the URL, everything is working fine. The page which includes jsp:forward tag is "testing.jsp", then call this page by using testing.jsp?r=<%=random value %>. This way forces the browser to reload the page each time instead of getting the page from the cache.

Kathy
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!