Assume that I have a java file, how can I wrap it into a serverlet? Is there any tutorial or procedure that I can follow?
Asked
Active
Viewed 108 times
-4
-
Its `Servlet`,and please expand this thing *wrap it into a servlet?* – jmj May 10 '11 at 19:38
-
1An hour or two reading this and you should be good to go - http://download.oracle.com/javaee/5/tutorial/doc/bnafd.html – planetjones May 10 '11 at 19:38
-
Just import, instantiate and use it the usual Java way. Further, try to learn how to spell "Servlet" correctly and peek around in our tag wiki page to get started http://stackoverflow.com/tags/servlets/info Try also to follow the links which are posted in your [previous question](http://stackoverflow.com/questions/5951415/java-servlet-and-java). – BalusC May 10 '11 at 19:39
-
@planetjones: How come Oracle stores several copies of everything? I found the same tutorial with different formatting and different URL. – Olaf May 10 '11 at 19:42
-
@BalusC, what if that class contains Swing code? ;) – Kaj May 10 '11 at 19:43
-
@Kaj: Ah that way, well if it is well designed according MVC, just replace V by JSP/HTML/CSS/JS and C by Servlet. – BalusC May 10 '11 at 19:44
-
@Olaf yeah they are all different versions, so I sent you a link to JEE5 tutorial. But the online content for Oracle now (Sun before) isn't exactly cohesively managed! – planetjones May 10 '11 at 19:45
2 Answers
1
Well, at that level of detail, no.
What does your java program do? If it's a GUI program, you're more or less out of luck -- a servlet is essentially text based.
If it's a text based program that just generates output, you can probably hack together a way to load the application and run the appropriate static main.
Even then, the truth is that the servlet model, based on being a web application, is a pretty different environment -- you may be able to reuse parts of your java application but have to rewrite a substantial bit to make it work.

Charlie Martin
- 110,348
- 25
- 193
- 263
0
Define "wrap".
If you are new to this, the Oracle Servlet Tuutorial is a good place to start: http://download.oracle.com/docs/cd/E19159-01/819-3669/6n5sg7avg/index.html

Olaf
- 6,249
- 1
- 19
- 37