How to store data in servlet like storing data in Application object in JSP!_NEWLINE_!and how to find the directoryname of a file
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sabu_vs
Posted On:   Friday, September 21, 2001 03:38 AM

Hi

In JSP we can store values in Application object.Any JSP file can access this data.
Is there any mechanism in servlet to store data like this.
Could you pls provide a sample code to store "name" like this.
I would like to know what happens to this data when the webserver closes.
Will i lose this data?



How can i find the directory name of a file.I have a java class file
"test.class" and I want to display the directory where this file resides.

Could you pls include a sample code


thanks

sabu

Re: How to store data in servlet like storing data in Application object in JSP!_NEWLINE_!and how to find the directoryname of a file

Posted By:   Alex_Chaffee  
Posted On:   Wednesday, September 26, 2001 12:41 PM

Re: How to store data in servlet like storing data in Application object in JSP!_NEWLINE_!and how to find the directoryname of a file

Posted By:   AlessandroA_Garbagnati  
Posted On:   Friday, September 21, 2001 08:18 AM

Hi,

Try not to put too many question at the same time because you will risk to get only one response.


The 'application' object of a JSP page is the 'ServletContext' of a servlet.

When, inside a JSP, you do:

application.setAttribute("name", object);

it's like doing:

request.getServletContext().setAttribute("name", object);

that is a syntax that is valid even inside a servlet.


When the servlet container shutdowns, all these information are lost. You can study a way to make them persinstence, maybe saving them in a file once in a while, and reading them on the startup.


For the last question, there was a thread or a FAQ related to this, so, please, do a search.

About | Sitemap | Contact