Package javax.servlet.http

Examples of javax.servlet.http.HttpServlet


    assertNotNull(getRequest());
    assertNotNull(getResponse());
    assertNotNull(getContext());
    assertNotNull(getSession());

    HttpServlet servlet = getServlet();

    assertNotNull(servlet.getServletConfig());
    assertNotNull(servlet.getServletContext());
    assertNotNull(servlet.getServletInfo());
  }
View Full Code Here


        filter.init(config);

        // the servlet to call at the end of the chain, just writes the provided content out
        // to the response
        Servlet servlet = new HttpServlet() {
            public void service(ServletRequest req, ServletResponse res) throws ServletException,
                    IOException {
                res.setContentType(contentType);
                PrintWriter writer = res.getWriter();
                BufferedReader reader = new BufferedReader(new StringReader(content));
View Full Code Here

    public void startJetty() throws Exception {
        // Loop until Jetty binds to an available port
        for (httpPort = MIN_DYNAMIC_PORT; httpPort <= MAX_PORT_NUMBER; httpPort++) {
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            context.setContextPath("/");
            HttpServlet testServlet = new TestServlet();
            context.addServlet(new ServletHolder(testServlet), "/*");
            jettyServer = new Server(new InetSocketAddress(HTTP_HOST, httpPort));
            jettyServer.setHandler(context);
            try {
                jettyServer.start();
View Full Code Here

    private int setupJettyServer() throws Exception {
        // Loop until Jetty binds to an available port
        for (int httpPort = MIN_DYNAMIC_PORT; httpPort <= MAX_PORT_NUMBER; httpPort++) {
            ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
            context.setContextPath("/");
            HttpServlet testServlet = new TestServlet();
            context.addServlet(new ServletHolder(testServlet), "/*");
            jettyServer = new Server(new InetSocketAddress(HTTP_HOST, httpPort));
            jettyServer.setHandler(context);
            try {
                jettyServer.start();
View Full Code Here

    /**
     * Returns any extra path information after the servlet name but before the query string,
     * and translates it to a real path. If the URL does not have any extra path information, this method returns null.
     **/
    public String getPathTranslated() {
        HttpServlet servlet = null;
        String path = getPathInfo();
        if( path == null ) {
            return null;
        }
        try {
            servlet = (HttpServlet)_servletRequest.getServlet();
        }
        catch( ServletException se ) {
            return null;
        }
        try {
            URL url = servlet.getServletContext().getResource( path );
            return url.getFile();
        } catch (MalformedURLException e) {
            return null;
        }
    }
View Full Code Here

    /**
     * Returns any extra path information after the servlet name but before the query string,
     * and translates it to a real path. If the URL does not have any extra path information, this method returns null.
     **/
    public String getPathTranslated() {
        HttpServlet servlet = null;
        String path = getPathInfo();
        if( path == null ) {
            return null;
        }
        try {
            servlet = (HttpServlet)_servletRequest.getServlet();
        }
        catch( ServletException se ) {
            return null;
        }
        try {
            URL url = servlet.getServletContext().getResource( path );
            return url.getFile();
        } catch (MalformedURLException e) {
            return null;
        }
    }
View Full Code Here

        node.start();
       
        // Mock up a test Web service on http://localhost:8086/wsupper
        jetty = new JettyServer((ExtensionPointRegistry)nf.getExtensionPointRegistry());
        jetty.start();
        jetty.addServletMapping("http://localhost:8086/wsupper", new HttpServlet() {
            private static final long serialVersionUID = 1L;
            protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
                assertTrue(read(req.getInputStream()).contains("Hello SOAP"));
                final String soapresp =
                    "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">" +
View Full Code Here

     *
     **/

    protected void setupForRequest(RequestContext context)
    {
        HttpServlet servlet = context.getServlet();
        ServletContext servletContext = servlet.getServletContext();
        HttpServletRequest request = context.getRequest();
        HttpSession session = context.getSession();

        if (session != null)
            _sessionId = context.getSession().getId();
View Full Code Here

    protected void loadBus(ServletConfig sc) {
        this.bus = BusFactory.newInstance().createBus();
    }

    private ServletController createServletController(ServletConfig servletConfig) {
        HttpServlet serviceListGeneratorServlet =
            new ServiceListGeneratorServlet(destinationRegistry, bus);
        ServletController newController =
            new ServletController(destinationRegistry,
                                  servletConfig,
                                  serviceListGeneratorServlet);       
View Full Code Here

        } else if(arg.startsWith("servlet=")) {     //adding custom servlet
           String servletCmd = arg.substring("servlet=".length());
           String[] halves = servletCmd.split("@");
           try {
             Class<?> servletClass = Class.forName(halves[0]);
             HttpServlet srvlet = (HttpServlet) servletClass.newInstance();
             if(!halves[1].startsWith("/"))
               halves[1] = "/" + halves[1];
             servletsToAdd.put(halves[1], srvlet);
           } catch(Exception e) {
             e.printStackTrace();
View Full Code Here

TOP

Related Classes of javax.servlet.http.HttpServlet

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.