tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Juan Carlos Fernández Galante <juan.carlos.fernan...@upcnet.es>
Subject Re: How can I execute a jsp from Catalina?
Date Tue, 27 Nov 2001 12:23:29 GMT

Thanks, for your help, but I want to make a Web Server, and I want to make
use of Catalina and Jasper Api.

I had achieved execute a servlet with the next code:
---------------------------------------------
 public Prueba1()
  {
  //Set the servlet Name and the servlet Class
  StandardWrapper theStandardWrapper = new StandardWrapper();
  theStandardWrapper.setServletName("servlet.OCSPServlet");
  theStandardWrapper.setServletClass("servlet.OCSPServlet");

  try
  {
   //Sets the loader
   WebappLoader theWebappLoader = new WebappLoader();
   theStandardWrapper.setLoader(theWebappLoader);
   Servlet theServlet = theStandardWrapper.allocate();

   //Generate the request
   HttpRequestBase theHttpRequestBase = new HttpRequestBase();
   String theRequest = createRequest();
   ByteArrayInputStream theInputStream = new
ByteArrayInputStream(theRequest.getBytes());

   theHttpRequestBase.setContentType("text/plain");
   theHttpRequestBase.setContentLength(theRequest.length());

   theHttpRequestBase.setStream(theInputStream);

   //Generate the response
   HttpResponseBase theHttpResponseBase = new HttpResponseBase();
   ByteArrayOutputStream theOutputStream = new ByteArrayOutputStream();


   // Call service method
   theServlet.service(theHttpRequestBase, theHttpResponseBase);


  }catch (Exception e)
   {
    e.printStackTrace();
   }
  }
---------------------------------------------
but I do not know how make it with jsp.



> If you have Tomcat 4.0 up and go ,  put the  jsp (myjsp.jsp) in :
> CATALINA_HOME
>     webapps/ROOT/myjsp.jsp
>
> In your browser type :
> http://localhost:port/myjsp.jsp
>
> you can try this  JSP:
>
> <!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'
> 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd'>
> <html>
>  <head>
>   <meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>
>   <title>JSP test</title>
>  </head>
>  <body>
>   <p>
>    HTML hello world
>   </p>
>   <%
>   out.println("<h1>JSP hello world</h1>");
>   %>
>  </body>
> </html>
>
>
> Juan Carlos Fernández Galante wrote:
>
> > Hi,
> >
> > I want to execute a jsp from, but I don´t know whats are the steps.
> >
> > --
> > To unsubscribe, e-mail:
<mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
<mailto:tomcat-dev-help@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
<mailto:tomcat-dev-help@jakarta.apache.org>
>
>



--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message