File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes can we use servlet as presentation layer in struts? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "can we use servlet as presentation layer in struts?" Watch "can we use servlet as presentation layer in struts?" New topic
Author

can we use servlet as presentation layer in struts?

Mandar Velankar
Ranch Hand

Joined: Jul 31, 2006
Posts: 32
Hi,
Just for curiosity can anybody tell me is it possible to use servlet as

presentation layer in struts, I tried by specifying servlet name in forward

attribute of actionmapping and done its entry in web.xml , but it throws

exception wrapper does not find servlet class.

Thanks a lot.

Wait for your replies.

Regards

Mandar Velankar
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
hmmm...generally Struts is considered a replacement for servlets but it seems like you should be able to forward to a servlet after your action is executed. Are you able to execute your servlet by entering the URL directly in your browser's address bar? If so then you just need to use the same URL in your forward.

- Brent
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Brent is right.. you can specify a Servlet as a forward, but you have to remember one thing: In this case you must specify redirect="true" when you define the forward.

Note: Just because you can do something doesn't mean you should do it. I think mixing Servlets and actions in an application is a really bad idea. An action can do anything a Servlet can, so why not write it as an Action? About the only situation I can see that such a mixture might make sense is if you have an existing application that uses Servlets, and you'd like to integrate it with a Struts application without completely rewriting it.
[ January 16, 2007: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
Mandar Velankar
Ranch Hand

Joined: Jul 31, 2006
Posts: 32
Thanks Brent & Merrill,

I got my mistake, I followed your instructions, it's working now.

I agree with Merrill , but I just done that for testing.

Thanks again,

Regards,

Mandar Velankar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we use servlet as presentation layer in struts?