portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sasi B <B.S...@sisl.co.in>
Subject How to Invoke Servlet
Date Wed, 27 Feb 2002 09:50:35 GMT
>  Hai EveryBody
>  
>  Recently i have installed JetSpeed. I would like to invoke a Servlet
> using ServletInvokerClass. but it is not taking the servlet class  file,
> it is showing blank page. where can i put the servlet .class file. Here I
> am sending the code. please suggest me.
>  
>  
>  1. ServletInvoker1.java which is under <JetSpeed-Home>/web-inf/classes
>  
>  public class ServletInvokerPortlet1 extends AbstractPortlet
>  {
>  
>      public ServletInvokerPortlet1()
>      {
>      }
>  
>      public ConcreteElement getContent(RunData rundata)
>      {
>          org.apache.jetspeed.portal.PortletConfig pc = getPortletConfig();
>          String servletURL = null;
>          try
>          {					
>              servletURL = getPortletConfig().getInitParameter("url");	
>              return new EcsServletElement(rundata, servletURL);   //
> Invoking The Servlet File Here.
>          }
>          catch(Exception e)
>          {
>              String message = "ServletInvokerPortlet: Error invoking " +
> servletURL + ": " + e.getMessage();
>              Log.error(message, e);
>              return new StringElement(message);
>          }
>      }
>  }
>  
>  2. The Servlet File which is also in the same directory as
> <JetSpeed-Home>/web-inf/classes
>  
> public class TestServlet extends HttpServlet
>  {
>  
>  	public void doGet(HttpServletRequest req, HttpServletResponse res)
> throws IOException,ServletException
>  	{	
>  		res.setContentType("text/html");
>  		PrintWriter out = res.getWriter();
>  		out.println("<HTML><HEAD><TITLE>");
>  		
>  		out.println("</TITLE></HEAD><BODY>");
>  		out.println("<H1> Hello</H1>");
>  		out.println("<P>This is output from SimpleServlet.");
>  		out.println("</BODY></HTML>");
>  		out.close();
>  
>  	}
>  }
>  
>  3. The Registry file  which is under <JetSpeed-Home>/web-inf/conf
>  
>  
>  <?xml version="1.0" encoding="UTF-8"?>
>  
>  <registry>
>  
>  <portlet-entry name="TestServlet" hidden="false" type="ref"
> parent="Servlet" application="false">
>      <meta-info>
>          <title>TestServlet</title>
>          <description>Test Servlet </description>
>      </meta-info>
>      <classname>ServletInvokerPortlet1</classname>	
>      <parameter name="url"
>              value="/TestServlet" hidden="false"/>
>  <media-type ref="html"/>
>  </portlet-entry>
>  
>   </registry>
>  
>  
>  please suggest me .where to put the servlet file.
[Sasi B]  


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


Mime
View raw message