You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Vineet <vi...@gmail.com> on 2008/09/29 17:01:36 UTC

Unable to invoke Action class from My java servlet

Hi I'm trying to invoke the Struts Action class through a Custom Servlet made
by me which is accepting request from outside world and based on a specific
parameter i need to redirect the request to appropriate action class.

How do i invoke the action class from my servlet?
I was trying to use RequestDispatcher() but not able to do so.
service() of my servlet:
	public void service(HttpServletRequest request, HttpServletResponse
response){
		System.out.println("This is the Custom Servlet");
		try{
		String attribs = request.getParameter("actionCategory");
		if(attribs.equalsIgnoreCase("rate") || attribs.equalsIgnoreCase("print")){
			System.out.println("calling rd");
			RequestDispatcher rd = request.getRequestDispatcher("action");
			System.out.println("after rd received::" + rd.getClass().getName());
			rd.forward(request, response);
		}
		}catch(IOException e){
			e.printStackTrace();
		}catch(ServletException ex){
			ex.printStackTrace();
		}
	}

Please suggest.
-- 
View this message in context: http://www.nabble.com/Unable-to-invoke-Action-class-from-My-java-servlet-tp19725620p19725620.html
Sent from the Struts - Dev mailing list archive at Nabble.com.

Re: Unable to invoke Action class from My java servlet

Posted by Dave Newton <ne...@yahoo.com>.
Please ask this question on the struts-user mailing list; the dev list is for the development of Struts itself.

Thanks,
Dave

--- On Mon, 9/29/08, Vineet wrote:
> Hi I'm trying to invoke the Struts Action class through
> a Custom Servlet made
> by me which is accepting request from outside world and
> based on a specific
> parameter i need to redirect the request to appropriate
> action class.
> 
> How do i invoke the action class from my servlet?
> I was trying to use RequestDispatcher() but not able to do
> so.
> service() of my servlet:
> 	public void service(HttpServletRequest request,
> HttpServletResponse
> response){
> 		System.out.println("This is the Custom
> Servlet");
> 		try{
> 		String attribs =
> request.getParameter("actionCategory");
> 		if(attribs.equalsIgnoreCase("rate") ||
> attribs.equalsIgnoreCase("print")){
> 			System.out.println("calling rd");
> 			RequestDispatcher rd =
> request.getRequestDispatcher("action");
> 			System.out.println("after rd received::" +
> rd.getClass().getName());
> 			rd.forward(request, response);
> 		}
> 		}catch(IOException e){
> 			e.printStackTrace();
> 		}catch(ServletException ex){
> 			ex.printStackTrace();
> 		}
> 	}
> 
> Please suggest.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org