There are 4 code examples for javax.servlet.http.HttpSession.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: openhotelsystem Package: it.hotel.controller.confirmedBooking

Source Code: ConfirmedBookingDelegate.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @param req
 * @param resp
 * @return
 */
public ModelAndView print(HttpServletRequest req,HttpServletResponse resp){
  HttpSession session=null;
  session=req.getSession();
  ServletContext context=session.getServletContext();
  String path=context.getRealPath("/");
  int id=Integer.parseInt(req.getParameter("id"));
  ConfirmedBooking confirmedBooking=bookingManager.getConfirmedBooking(id);
  bookingManager.updateConfirmedBookingWithTodaysDateIfNecessary(confirmedBooking);
  ConfirmedBookingDTO confirmedBookingDTO=new ConfirmedBookingDTO(confirmedBooking);
  ConfirmedBookingReportMaker report=new ConfirmedBookingReportMaker(confirmedBooking);
  OutputStream out=null;
  try {
    out=resp.getOutputStream();
    report.createReport(path,out);
  }
 catch (  IOException e) {
    e.printStackTrace();
  }
  return new ModelAndView("hotel.confirmedBooking.view","confirmedBooking",confirmedBookingDTO);
}
 

Project Name: openhotelsystem Package: it.hotel.controller.photo

Source Code: PhotoControllerDelegate.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @param req
 * @param resp
 * @return
 */
public ModelAndView delete(HttpServletRequest req,HttpServletResponse resp){
  String id=req.getParameter("id");
  Photo photo=(Photo)photoManager.get(Integer.parseInt(id));
  photoManager.remove(Integer.parseInt(id));
  HttpSession session=null;
  session=req.getSession();
  ServletContext context=session.getServletContext();
  String path=context.getRealPath("/");
  DirectoryUtils.deleteFile(path + photo.getUrl() + "/small/"+ photo.getName()+ ".jpeg");
  DirectoryUtils.deleteFile(path + photo.getUrl() + "/big/"+ photo.getName()+ ".jpeg");
  return new ModelAndView("redirect:/photo/new.htm");
}
 

Project Name: openhotelsystem Package: it.hotel.view.tags

Source Code: CheckNotPermissionTag.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @throws
	 * @
 * return
 */
public int doStartTag() throws JspException {
  HttpSession session=this.pageContext.getSession();
  try {
    boolean isAuthorized=false;
    WebApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
    UserContainer container=(UserContainer)context.getBean("userContainer");
    IUser user=container.getUser();
    Role role=user.getRole();
    if (role != null) {
      isAuthorized=!(role.hasPermission(this._permission) || role.getName().equalsIgnoreCase(_permission));
    }
    if (isAuthorized) {
      return EVAL_BODY_INCLUDE;
    }
 else {
      return SKIP_BODY;
    }
  }
 catch (  Throwable t) {
    SystemUtils.logThrowable(t,this,"doStartTag");
    throw new JspException("Error initialising tag",t);
  }
}
 

Project Name: openhotelsystem Package: it.hotel.view.tags

Source Code: CheckPermissionTag.java (Click to view .java file)

Method Code:
vote
like

/** 
 * @throws
	 * @
 * return
 */
public int doStartTag() throws JspException {
  HttpSession session=this.pageContext.getSession();
  try {
    boolean isAuthorized=false;
    WebApplicationContext context=WebApplicationContextUtils.getWebApplicationContext(pageContext.getServletContext());
    UserContainer container=(UserContainer)context.getBean("userContainer");
    IUser user=container.getUser();
    Role role=user.getRole();
    if (role != null) {
      isAuthorized=(role.hasPermission(this._permission) || role.hasPermission(Permission.SUPERUSER) || role.getName().equalsIgnoreCase(_permission));
    }
    if (isAuthorized) {
      return EVAL_BODY_INCLUDE;
    }
 else {
      return SKIP_BODY;
    }
  }
 catch (  Throwable t) {
    SystemUtils.logThrowable(t,this,"doStartTag");
    throw new JspException("Error initialising tag",t);
  }
}