wood burning stoves 2.0*
The moose likes JSP and the fly likes Access session variable in JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Access session variable in JavaScript" Watch "Access session variable in JavaScript" New topic
Author

Access session variable in JavaScript

Varsha Garud
Greenhorn

Joined: Jan 18, 2013
Posts: 2
Same here i want to access a session variable in javascript..
in java i can access it by getServletContext().getInitParameter("DATE_FORMAT") (where DATE_FORMAT is my session variable)
I want to access this varaible in javascript..How to do that??
Might be a lame question but need help..
Thank you in advance [/color]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

You can't. Not directly.

What you can do to is to create JavaScript markup that assign the value to a JavaScript variable. As in:
assuming that the value is a String.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Access session variable in JavaScript
 
Similar Threads
Problem in calling javascript function
how to store value from servlet to java script variable
Accessing php session variable in JavaScript
how to get session value in javascript
Applying style to a variable