aspose file tools*
The moose likes Servlets and the fly likes Accessing Servlet methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Accessing Servlet methods" Watch "Accessing Servlet methods" New topic
Author

Accessing Servlet methods

Jeremy Wilson
Ranch Hand

Joined: Feb 18, 2003
Posts: 166
How would an ejb client of a servlet, call a servlet method such as
public boolean sendFiles(String[] names, String site){
}


Jeremy Wilson
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17259
    
    6

Well, I think the question needs to be raised about the design, more than how an EJB can call a method on a Servlet.
The big question then is why is that method in the Servlet and not in an seperate helper class that both Servlet and EJB can call? Or even in a Session EJB.
The way I always think of Servlets are work done in the service type methods, doPost, doGet, doHead, etc. They respond to a request and send stuff back, if needed. The Servlet, itself might have private methods that the Servlet needs. (Which I still think that these methods should be in a different class)
But the Servlet should not have methods that outside classes need to call.
My Opinion of course.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
Mark hit the nail on the head.
I've never done what you want to do but you should be able to instantiate the class just like any other as long as there is a constructor and then just invoke the method.


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing Servlet methods