public void service ( ServletRequest request , ServletResponse response ) throws IOException , ServletException { HttpServletRequest req = ( HttpServletRequest ) request ; HttpServletResponse res = ( HttpServletResponse ) response ; if ( ! req . getMethod ( ) . equals ( "POST" ) ) { res . setStatus ( 500 ) ; // , "Hessian Requires POST"); PrintWriter out = res . getWriter ( ) ; res . setContentType ( "text/html" ) ; out . println ( "<h1>Hessian Requires POST</h1>" ) ; return ; } String serviceId = req . getPathInfo ( ) ; String objectId = req . getParameter ( "id" ) ; if ( objectId == null ) objectId = req . getParameter ( "ejbid" ) ; ServiceContext . begin ( req , res , serviceId , objectId ) ; try { InputStream is = request . getInputStream ( ) ; OutputStream os = response . getOutputStream ( ) ; response . setContentType ( "x-application/hessian" ) ; SerializerFactory serializerFactory = getSerializerFactory ( ) ; invoke ( is , os , objectId , serializerFactory ) ; } catch ( RuntimeException e ) { throw e ; } catch ( ServletException e ) { throw e ; } catch ( Throwable e ) { throw new ServletException ( e ) ; } finally { ServiceContext . end ( ) ; } }
Execute a request . The path - info of the request selects the bean . Once the bean s selected it will be applied .