Reputation: 191
Hi im new in jsp/servlets, i have a basic question about relative or abselute path: i have the following hierarchy, using netbeans:
Web Pages
| |-Status
| |-clientRequests.jsp
| |-index.jsp
| |-WEB-INF
| |-professional.jsp
index.jsp
and the Status folder and WEB-INF
folder in root path.
inside the Status folder we have the clientRequests.jsp
file.
inside the WEB-INF folder we have the professional.jsp
file.
in the index.jsp i have done dispacher to professional.jsp
,
inside professional jsp i have <iframe src="Status/clientsRequests.jsp"></iframe>
inside the clientsRequests.jsp
i have
<%
response.setHeader("Refresh", "5;url=../index.jsp");
%>
that means that every 5 sec will be refresh to the clientsRequests.jsp
file, and then go to the "controller" which is index.jsp
.
now what i wanted to be that every 5 min, only the iframe refreshed and not the hole page.
my problem: in the second refresh it gives me 404.
i tried to play with that and i did something ugly like:
String a = (String)session.getAttribute("nav");
if(a == null){
session.setAttribute("nav", "aaa");
response.setHeader("Refresh", "5;url=../index.jsp");
}else{
response.setHeader("Refresh", "5;url=index.jsp");
}
and its working, but i dont want wo leave that like this way... do you have any suggestions? thank you!
Upvotes: 0
Views: 554
Reputation: 4873
one Alternative would be to move the clientRequests.jsp to the same level as index.jsp
.
That way in your code you can always do this
response.setHeader("Refresh", "5;url=index.jsp");
One advantage is with this set up , the <iframe src="Status/clientsRequests.jsp"></iframe>
can be added to any of the JSP pages in your application and there is no change/impact in the servlet code
Upvotes: 1
Reputation: 2796
Somehow your response is setting header for the parent of the iframe too. Put the below line in the of clientsRequests.jsp.
<meta http-equiv="refresh" content="5">
Upvotes: 1