IntelliJ Java IDE
The moose likes JSP and the fly likes Is it possible to use JSP to update something when a link is clicked? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "Is it possible to use JSP to update something when a link is clicked?" Watch "Is it possible to use JSP to update something when a link is clicked?" New topic
Author

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

Toni Howlett
Greenhorn

Joined: Jan 18, 2012
Posts: 25
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
Bartender

Joined: Oct 14, 2005
Posts: 13842

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
Greenhorn

Joined: Jan 18, 2012
Posts: 25
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 opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

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.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
Toni Howlett
Greenhorn

Joined: Jan 18, 2012
Posts: 25
@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 opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

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
Greenhorn

Joined: Jan 18, 2012
Posts: 25
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 opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50693

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.
 
 
subject: Is it possible to use JSP to update something when a link is clicked?
 
Threads others viewed
Change value in form onClick
Ajax and Jquery
Struts 2.1.6: keeping information in the same div - using tree node
problem in paging using javascript
How to read cookie-name from weblogic.xml in Servlet or JSP ?
developer file tools