dcsimg
JSP-Writing message permanently into the JSP page
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mikael_Martin
Posted On:   Thursday, February 5, 2004 12:10 AM

Hi,
I have a jsp in which I ask the user to enter the message in textarea. once they submit the form it should write the message in the next page permanently and when the second user submit it should write next to the first message. can anyone help me how to do that. if anyone has code send it to mictin2003@yahoo.com. thankyou.

Re: JSP-Writing message permanently into the JSP page

Posted By:   gaz_rat  
Posted On:   Friday, February 6, 2004 08:20 AM

Mikael
I would do this by having the action on the form page call a servlet, this servlet would maintain a file that contained the text from the form, ie write the latest entry from the form to the file.
Then you read all the data from the file into a variable set it in the session or pass it in the query string and redirect the servlet to the jsp page that displays the results.

This way you keep the entered data between server restarts

Another way (may work I havent tried it) of doing this that would not keep the info between server restarts would be to use a bean that had its scope set to application. Your form page would call the display page which then took the value, used a set method of the bean to add to the existing message, a get method to get the total message and then display it. I think with the bean being at application scope all users would see the same message?? I could well be talking rubbish, Ill try it if I have time and post the results here.

Hope this helps
gaz

ps If you struggle writing the code Ill post some but try and figure it out first :)

About | Sitemap | Contact