1 33 package net.myvietnam.mvncore.web.impl; 34 35 import javax.servlet.ServletContext ; 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletRequestWrapper ; 38 39 import net.myvietnam.mvncore.web.GenericRequest; 40 41 public class GenericRequestServletImpl extends HttpServletRequestWrapper implements GenericRequest { 42 43 private ServletContext context; 44 45 public GenericRequestServletImpl(HttpServletRequest request) { 46 super(request); 47 } 48 49 public GenericRequestServletImpl(HttpServletRequest request, ServletContext context) { 50 super(request); 51 this.context = context; 52 } 53 54 public HttpServletRequest getServletRequest() { 55 return (HttpServletRequest )getRequest(); 56 } 57 58 public Object getPortletRequest() { 59 return null; 60 } 61 62 public boolean isServletRequest() { 63 return true; 64 } 65 66 public boolean isPortletRequest() { 67 return false; 68 } 69 70 public String getSessionId() { 71 return this.getSession().getId(); 72 } 73 74 public String getRealPath(String path) { 75 if (context == null) { 76 throw new IllegalStateException ("Cannot getRealPath with a null context."); 77 } 78 79 return context.getRealPath(path); 80 } 81 82 public void setSessionAttribute(String name, Object value) { 83 this.getSession().setAttribute(name, value); 84 } 85 86 public Object getSessionAttribute(String name) { 87 return this.getSession().getAttribute(name); 88 } 89 90 } 91 | Popular Tags |