aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes setting a session attribute from javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "setting a session attribute from javascript" Watch "setting a session attribute from javascript" New topic
Author

setting a session attribute from javascript

Ayan Dutta
Ranch Hand

Joined: Oct 16, 2005
Posts: 94
Hi , I need to write a javascript method that sets a session attribute .
This can be done quite easily using scriplet .
But there is a problem .
Say the method is like ...

funtion xyz()
{
if(condition1)
...scriplet code for setting the session attribute
else
...do something else
}

Now when the page containing the method xyz() is loaded ,as the scriplet executes before the javascript ,even if the method xyz() is not invoked ,
the scriplet will get executed.which is not desired.
I know it is not a very good practise to use scriplet from javascript,but the situation is like that.Any work around to prevent this scriplet execution ,when the method is not invoked ?
Regards,
Ayan
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
JavaScript can not do it.

Please read this: http://www.javaranch.com/journal/200510/Journal200510.jsp#a1

Eric
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Originally posted by Ayan Dutta:

I know it is not a very good practise to use scriplet from javascript...


It's not a bad practice, it's impossible. Please read this article to find out why.

You'll have to submit a form or make an Ajax request to have a server-side effect as a result of a client-side event.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

Great minds think alike...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: setting a session attribute from javascript