Keeping track of sessions?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   john_omeara
Posted On:   Saturday, January 3, 2004 11:39 AM

Hello



I have created a jsp page which lets users submitt web pages to a database. when the user accesses a page called frontpage.jsp he or she is greeted with a form to fill in there details. After the user has submitted this info he or she is directed back to frontpage.jsp. Does anyone know how i could bring up a line saying submission succesful if the details were stored successfully and how to omitt this statement if the user has accessed the page for the first time in that session.



many thanks

Re: Keeping track of sessions?

Posted By:   Anin_Mathen  
Posted On:   Monday, January 5, 2004 11:20 AM

John,

Here's a simple answer. The proper way to do it would be to use a MVC model. But I am assuming you just want one page to do all your stuff.


Consider a form that has some fields and a save button.





...




When the "Save" button is clicked, the value of the save button is also sent along with the rest of the fields. So the only time the server gets the Save button is when someone posts to the page.



<%
String message="";
String saveButton= request.getParameter("save");
if (saveButton!=null) {
//the save button was clicked.
//so save the contents of the page...
//then present a message
message = "Your contents have been saved...";
}
%>

Notice how the message variable is initialized to blank initially and only set to some value if a save operation is invoked.


Then somewhere in your frontpage.jsp display the message

<%= message %>

Hope this helps.


Anin
About | Sitemap | Contact