servlet
e.g. PDFCreateAndView.java
CompanyProfile bean = (CompanyProfile) request.getSession().getAttribute("bean");
allDocGenPDF.logoSizeFactor=bean.getLogoSizeFactor();
http://stackoverflow.com/questions/2663079/java-servlet-and-jsp-accessing-the-same-session-bean
The basic semantic tries to find an existing object using id and scope. If the object is not found it will attempt to create the object using the other attributes.
In other words,
<jsp:useBean id="user" scope="session" class="package.name.User"/>
would translate roughly into java as:
package.name.User user = (package.name.User)session.getAttribute("user");
if (user == null){
user = new package.name.User();
session.setAttribute("user", user);
}
沒有留言:
張貼留言