Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3827
  • Last Modified:

JSP Session Refresh Problem

Hi,

I have a left and right frame pages. Each frame gets refresh for a certain value get from interval.java
Now Left Frame has the Tree Nodes, when you click on any node, the output is print on right frame.
This is kinda links on nodes: "Detail.jsp?Id=@id"
This detail.jsp takes the Id as parameter and displays in right frame, also I'm saving this Id as sesstion.setAttribute in order to navigate to other jsp pages(right frames only) which required parameter as id. So the problem is as I said after every few sec/min left frame & right frame gets refresh. Once the left frame get refresh, the right page (Detail.jsp or other jsp pages) gives error by saying null values for id.

Is it that when left frame gets refresh, the session get clear on right frame pages too. ?? What is the proper way to solve this. Please hlep out.

Regards
0
princehyderabad
Asked:
princehyderabad
  • 3
  • 2
  • 2
  • +3
2 Solutions
 
justywongCommented:
you mean auto refresh using meta tag?
remember to add the ID value in your refresh url.

e.g.
<meta http-equiv="refresh" content="180;URL=Detail.jsp?Id=<%=id%>">
0
 
princehyderabadAuthor Commented:
No my friend, read it again.
Left Frame refresh sec/min is get from JSP1
Right Frame refresh sec/min is get from JSP2

Everytime Left gets refresh, the right page which stores session values passed as a getParameter from left frame becoming null. How can I save session ? Even after left frame get refresh the right page should hv the session value but not null
0
 
justywongCommented:
can you post your code?

you set the session attribute whenever ur left frame refresh?
if your refresh url didn't have the parameter, you jsp will get a null from it and set to session.
so u've to check before u set your attribute.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
princehyderabadAuthor Commented:
Left Frame has Menus. ONce you click on the any menu. The page is opened in the right frame. This is my Right Frame code.
Values  are passed using getParameter Id, IpAddress, Name as you can see the below code.

<%@ page session="true" %>
<% String id = request.getParameter("Id");
   String ipa = request.getParameter("IpAddress");
   String sn = request.getParameter("Name");

      if(id==null){
                          id = (String)session.getAttribute("id");
      }
            if(ipa==null){
                         ipa = "default";
      }
     
      if (id!=null)
      {
      session.setAttribute("id",id);
      session.setAttribute("ipa",ipa);
      session.setAttribute("sn",sn);
      }
 %>
<html>
<head>
<jsp:include page="/resource/GetResourcePollingInterval">
     <jsp:param name="mm.resourceId" value="<%=id%>" />
</jsp:include>
<meta http-equiv="refresh" content="<%=request.getAttribute(INTERVAL)%>;url=http://localhost:8080/ResourceMonitor.jsp">

==========================================
Left Frame Refresh code:

<jsp:include page="/resource/GetResourcePollingInterval">
     <jsp:param name="mm.resourceId" value="<%=id%>" />
</jsp:include>
<meta http-equiv="refresh" content="<%=request.getAttribute(INTERVAL)%>;url=http://localhost:8080/ResourceMonitor.jsp">

================================

So once the left frame gets refresh, the right page also refresh at same interval and gives the "null" value for Id and refreshs to error page saying String null...
0
 
justywongCommented:
your code seems ok........... I tested it too and work fine.

1 more question, just want to make sure..... did u turn off your cookies in browser?
Sorry that can't help you.
0
 
sudhakar_koundinyaCommented:
The following page should be called some thing like this

http://YourServer/YourPath/Yourpage.jsp?id=YourID

Otherwise your request is always null

or if you are using forward then
<%
String id = request.geAttribute("Id");
%>




<%@ page session="true" %>
<% String id = request.getParameter("Id");
   String ipa = request.getParameter("IpAddress");
   String sn = request.getParameter("Name");

      if(id==null){
                          id = (String)session.getAttribute("id");
      }
            if(ipa==null){
                         ipa = "default";
      }
     
      if (id!=null)
      {
      session.setAttribute("id",id);
0
 
spiderman19Commented:
0
 
NdivhuwoCommented:
what is the difference between jsp and javascript
0
 
sudhakar_koundinyaCommented:
>>what is the difference between jsp and javascript

You should ask with ur own question

Anyways
JSP(Java Sever Pages) is Java based server side program

JavaScript can be either serverside or client side script language. Most of the people use Javascript to validate the html fields or to submit the html fields to Server Pages

0
 
parmanzCommented:
when i invoke a jsp page..initially the page passes null value to the servlet page which is called using <jsp:forward>..how can i rectify the problem
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now