Solved

JSP Session Refresh Problem

Posted on 2004-08-11
10
3,700 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java.util.concurrent.locks in java 3 199
dateFashion java challenge 9 146
lessBy10  challenge 15 95
jsp login check 12 43
Building a successful professional career is a long and difficult journey, especially in case if your decisions are not chosen carefully. For example, if you think that you can get to the desired position without experience and apply for it, your ch…
Smart phones, smart watches, Bluetooth-connected devices—the IoT is all around us. In this article, we take a look at the security implications of our highly connected world.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

820 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