Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to use JSP to update something when a link is clicked?  RSS feed

 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, I am using javascript with a toggle function to hide/show part of my page (and I have this saved in a cookie) but I want to switch over from cookies to my properties file. I want to recreate this same function, but using JSP so that I can save it to my properties file easily.

the link hide/shows the div under it


this is the function I have



So is there a way I can do this with JSP? (or at least save if its hidden or showing with jsp?)
 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You seem to be asking about that Javascript code. But then you mentioned a "properties file", which is surely a file on the server, isn't it? So I'm confused. Do you want to do something on the server, or on the client? You do know that the JSP runs on the server and generates HTML plus Javascript, which is sent to the browser to be run, right?
 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I do realize that.

Is there a way that I can use JSP to at least save if it is currently hidden or shown?

I want to get away from using cookies and use the properties file instead.

Is that better explained?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. The JSP executes on the server to create the HTML to send to the client. Once the response is sent, there's no more JSP-ness.

Please read this article to understand how JSP works.

You'll need to send a request back to the server to affect any server state.
 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Bear well my other topic isn't being discussed here... but I suppose now it has to be considering it got locked.
I had trouble explaining my situation but that was going to be part of a page that was going to have a submit button. While this topic, I don't have a submit button and I need to save something to a properties file when its clicked.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Both topics are different angles of the same problem. Better to discuss within a single topic than spread it over two or more.

You don't need a submit button to create a request. You could, for example, employ Ajax.
 
Toni Howlett
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no experence what so ever with Ajax. What kind of code should I look for for what i'm trying to do?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65826
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want to send info to the server behind-the-scenes, Ajax is the way to go.

Use your google-fu to find out all about Ajax. I'd start with this article.

P.S. Few seasoned developers will write raw Ajax code. Rather, a library such as jQuery or YUI makes life a lot simpler.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!