Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing Servlet methods

 
Jeremy Wilson
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How would an ejb client of a servlet, call a servlet method such as
public boolean sendFiles(String[] names, String site){
}
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic