How to convert a given java program into jsp/servlet ?
I have a ready java program which needs to be made web-based. What should I do ??? Preferably, I want to deal with jsp/servlet.
Any suggestions/directions ?
Pls help….
No related posts.
This option will reset the home page of this site. Restoring any closed widgets or categories.
ResetI have a ready java program which needs to be made web-based. What should I do ??? Preferably, I want to deal with jsp/servlet.
Any suggestions/directions ?
Pls help….
No related posts.
This post was written by admin on Friday, December 25, 2009, 22:55. admin has written 13366 posts on this blog.
You can subscribe by RSS feed or by e-mail to receive news updates and breaking stories.
Copyright © 2012 Afia Tech. All rights reserved.
Powered by WordPress. Designed by Deluxe Themes
Depending on what kind of program it is, it could be as easy as taking the class that has the main() method in it, making it a subclass of HttpServlet and taking everything that’s in the main() method and putting it in the doGet() method of the servlet. Then you’d replace all the System.out.println() statements with statements to print the output in HTML. This would work if it’s just a command line program without a GUI (Graphical User Interface).
If your program has no GUI then you can stop reading here. If it does have a GUI, then it could be a lot more complicated. Depending on what kind of program it is, you could do one of the following:
1. Put the whole thing in an Applet.
This is pretty simple. Instead of replacing a few lines to turn the program into a Servlet, you’d be replacing a few lines to turn it into an Applet. This you could do if you don’t need the server to communicate with, like if you had a solitare game. Otherwise, you could do #2.
2. Put the GUI in an Applet and keep the back end on the server.
This is what you’d call a “client/server” application.
3. Create a JSP/Servlet based website.
The most complicated option, but if you don’t want to use Applets this is the only way to go. Here you’re changing from a Java based GUI to an HTML/CSS based GUI. You might also need some JavaScript. If you’re not familiar with all this stuff, but you’re comfortable making Java GUI’s using things like Swing, you might want to check out GWT (Google Web Toolkit). This allows you to make rich websites using plain Java. The Java code “compiles” into HTML and Javascript.
Learn how to create a Servlet. Search for a tutorial………