noijet
asked on
Keeping values after refreshing...
Hi, I am creating a jsp file that has a checkbox and a select box. There are also two buttons: one "Run" button that will run something give the choices in the checkbox and select box, and the second "Apply Settings" button applies the settings so that if a user presses the "Run" button, the choices that the user picked right before clicking apply settings will be in affect. Is there a way to keep the choices selected (choices that the user choose after clicking the "Apply Settings" button) even when the user performs a refresh on the page? Currently, if the user clicks refresh, all the default values are selected.
If possible, please provide some sample code. Any comments or suggestions are well appreciated.
Thanks,
noijet.
If possible, please provide some sample code. Any comments or suggestions are well appreciated.
Thanks,
noijet.
ASKER
Thank you MogalManic, I am currently on another urgent project, but I will get back as soon as possible, thanks again!
-noijet
-noijet
ASKER
Hi MogalManic, thanks for your comment and sorry for the delay !.
Is there a way to do this using hidden fields or cookies? I have always thought cookies are like sessions, am I right?
Thanks,
noijet.
Is there a way to do this using hidden fields or cookies? I have always thought cookies are like sessions, am I right?
Thanks,
noijet.
Oh yea,
Sometimes the simplest solutions are the best! I don;t have time right now to do a full blown and tested page but it would be something like this:
<body onload='setOptions()'>
<form name='runForm' method='post'>
<input type='checkbox' name='checkbox1' >
<input type='button' name='run' value='run' onclick='javascript:run()' />
<input type='button' name='Apply' value='ApplySettings' onclick='onclick='setCooki e("checkbo x1", "this.checked", (new Date())+5000 /*5 seconds from now*//)'/>
</form>
To answer your cookie & session question:
The Java servlet uses cookies for the Session ID and the session data is then stored on the server and mapped to the user via the session ID. This means that sessions are a little more secure than cookies because the user does not directly know what is stored. If you use an all cookie solution, then the user CAN (probably does not know how) view the cookies on his hard drive.
Sometimes the simplest solutions are the best! I don;t have time right now to do a full blown and tested page but it would be something like this:
<body onload='setOptions()'>
<form name='runForm' method='post'>
<input type='checkbox' name='checkbox1' >
<input type='button' name='run' value='run' onclick='javascript:run()'
<input type='button' name='Apply' value='ApplySettings' onclick='onclick='setCooki
</form>
To answer your cookie & session question:
The Java servlet uses cookies for the Session ID and the session data is then stored on the server and mapped to the user via the session ID. This means that sessions are a little more secure than cookies because the user does not directly know what is stored. If you use an all cookie solution, then the user CAN (probably does not know how) view the cookies on his hard drive.
ASKER
Thank you for your very informative and excellent answer MogalManic. Regarding cookies, what risk would it be to allow users to view the cookies on his hard drive, could the user use that to break into my server or something? I would probably store the user's name, address so that the user doesn't have to type it again on another page or for some other action.
Thank you,
noijet.
Thank you,
noijet.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks MogalManic, so if they do manually change the cookie data, they would only be doing this on their own local machines?
Thanks,
noijet.
Thanks,
noijet.
ASKER
Hi MogalManic, an off-topic question, do you know how to get an image next to the web address, sort of like how experts-exchange has it?
(I didn't want to write another question, but I added some points though)
Thanks noijet
(I didn't want to write another question, but I added some points though)
Thanks noijet
I'm not sure that I understand the question. Do you mean this:
<a href='/nextImage><img src="next.gif"></a>
<a href='/nextImage><img src="next.gif"></a>
ASKER
Thanks MogalManic for your comment, I meant on the Address bar near the top of our webbrowser. On the left side of "http://www.experts-excha..., there is a image, can we change that?
Thanks again,
noijet.
Thanks again,
noijet.
ASKER
Hi, I currently have a question open regarding using Tomcat and ServletExec Application servers, if you have some comments please check out question: "Working with Tomcat and ServletExec on IIS..." https://www.experts-exchange.com/questions/21143102/Working-with-Tomcat-and-ServletExec-on-IIS.html
Thank you !
noijet
Thank you !
noijet
ASKER
Hi everybody ! If possible, can you take a look this question regrading a mysterious scrollbar appearing in Netscape 7.2 but not in Netscape 7.1 or IE?
At link: https://www.experts-exchange.com/questions/21186370/Mysterious-scrollbar-in-Netscape-7-2-but-not-in-7-1-or-IE.html
Thank you !
noijet
At link: https://www.experts-exchange.com/questions/21186370/Mysterious-scrollbar-in-Netscape-7-2-but-not-in-7-1-or-IE.html
Thank you !
noijet
<form name='runForm' method='post'>
<input type='checkbox' name='checkbox1'
<%if (session.getAttribute('che
%>checked='true'<%
}%>/>
<input type='button' name='run' value='run' onclick='javascript:run()'
<input type='button' name='Apply' value='ApplySettings' onclick='javascript:apply(
</form>
<%
if (request.getMethod().equal
if (request.getAttribute("che
session.setAttribute("chec
}
%>