Solved

JSP Session Refresh Problem

Posted on 2004-08-11
10
3,655 Views
Last Modified: 2008-02-01
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
Comment
Question by:princehyderabad
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 1

Expert Comment

by:justywong
ID: 11779976
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
 

Author Comment

by:princehyderabad
ID: 11780058
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
 
LVL 1

Expert Comment

by:justywong
ID: 11780084
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
 

Author Comment

by:princehyderabad
ID: 11780125
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
 
LVL 1

Assisted Solution

by:justywong
justywong earned 25 total points
ID: 11780222
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 14

Accepted Solution

by:
sudhakar_koundinya earned 100 total points
ID: 11856586
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
 

Expert Comment

by:spiderman19
ID: 12005938
0
 

Expert Comment

by:Ndivhuwo
ID: 12062789
what is the difference between jsp and javascript
0
 
LVL 14

Expert Comment

by:sudhakar_koundinya
ID: 12062890
>>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
 

Expert Comment

by:parmanz
ID: 12346235
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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
We have come a long way with backup and data protection — from backing up to floppies, external drives, CDs, Blu-ray, flash drives, SSD drives, and now to the cloud.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now