开发者

variable across different jsp pages

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜