• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using GenericServlet for FTP

 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to extend GenericServlet to support FTP . What are the steps involved. I am not only interested in using GenericServlet to support FTP and not any other solution. Thanks./
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15452
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is not really possible to make servlets for handling other protocols than HTTP.

The protocol is handled by the servlet container, not the servlet itself. If you want to have FTP commands sent to a servlet, you need a special servlet container that handles the FTP protocol and sends the received FTP commands to a servlet. As far as I know there are no servlet containers available that can do this.
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper is right -- since Tomcat is open-source you COULD dive into the guts of the container and do it but that's a PhD-thesis sized project...

Kyle
 
Scott Dunbar
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the the Javadoc the only method that you must override is service(). You could look at the patterns used in HttpServlet to get some ideas. For the FTP protocol I could see things like doPut(), doGet(), doList(), and so on. You service() method would parse appropriately and call those methods on a FTPServlet.

The real issue, as was pointed out, is that the container handles the actual protocol. This is a not so subtle side effect of the J2EE servlet specification. Sure, you could have a FTPServlet, a SMTPServlet, and whatever other kind of protocol you want. But at the lowest level something has to be listening for a connection on a particular port and route packets to and from that port appropriately. Tomcat follows the servlet spec but doesn't have a Connector (a Tomcat term) for FTP. It really wouldn't be too bad to write one. Looking at the docs for Http11Processor you'll see that it implements two interfaces. Basically you want to create your own connector for Tomcat.

All of this is great, but forget about portability. If you want this to work in WebLogic or WebSphere you'll have to figure out their API's too.

I don't know that this is quite PhD level but is isn't trival either.
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys for your replies.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic