469,323 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

JSP Session in JavaScript variable problem

101 100+
Hi,


I have a session variable msgSize that is being set by a Java file in the session.
Expand|Select|Wrap|Line Numbers
  1. aRequest.getSession().setAttribute("msgSize", msgSize);
It's value is variable depends on record count of recordset.


In JSP page where I have to assign it's value to a javascript variable. I am doing this a s follows. I have done this in the JSP file.

[PHP]<script type="text/javascript" >
<!--
function getVal()
{
m=${msgSize};
}
-->
</script>[/PHP]

First Problem is I am unable to get this value inside a External JS file. It throws error but inside jsp it is working. How can i use this inside External JS?

Second problem is once the above code executed value never refreshed to new value?
Means first time it executed it get value 200 next time again i executed the code the real recordset is 105 but still displaying 200. But when I restart the server next time it takes value 105 by itself....

How I tacckle this problem.?


Regards,
Nov 18 '07 #1
2 8183
buntyindia
101 100+
problem is I am not refreshing the whole page, refreshing the partial page using ajax call that's why not getting the session new value...

any suggestions ?
Nov 18 '07 #2
acoder
16,027 Expert Mod 8TB
First Problem is I am unable to get this value inside a External JS file. It throws error but inside jsp it is working. How can i use this inside External JS?

Second problem is once the above code executed value never refreshed to new value?
You won't be able to use this in an external JS file because it's JavaScript and not JSP. You could try using JSP to render JavaScript output and link to it.

In your JSP code that gets called using Ajax, do you output the session variable and how are you attempting to get the value? Show your code.
Nov 19 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Joe Molloy | last post: by
26 posts views Thread by BillE | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
10 posts views Thread by sheldonlg | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Gurmeet2796 | last post: by
reply views Thread by mdpf | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.