开发者

variable across different jsp pages

开发者 https://www.devze.com 2023-01-29 20:09 出处:网络
I have a hashtable which i would be accessing from many jsp pages of my application. I dont unders开发者_如何学Pythontand where to declare hashtable.plz helpYou can keep it in application scope which

I have a hashtable which i would be accessing from many jsp pages of my application. I dont unders开发者_如何学Pythontand where to declare hashtable.plz help


You can keep it in application scope which will make it available to all jsp pages (plus the rest of your application).

<jsp:useBean id="myHashtable" class="java.util.Hashtable" scope="application" />

By including the above line in your jsp pages, they will all share the same instance (per server, different servers will have different instances). If the Hashtable doesn't exist when the jsp page is loaded, the container will create it.


Sounds like it would be an application object:

application.setAttribute( "myApplicationHashTable", myHashTable );

http://www.gulland.com/courses/JavaServerPages/jsp_objects3.jsp

0

精彩评论

暂无评论...
验证码 换一张
取 消