I have made a chat application using jsp and servlets.. It is running smoothly..Now If i want to change my client side from jsp to swing.. then is it possible to do so by using the same servlets and the same class that are using by the servlet? Tell me the necessary steps to do the same..
Thank You, Siddharth
Joined: Feb 03, 2005
hello this was the rearest mistake done Please delete the topic which is my humble request as i have posted a new topic already Administrators please do the necessary
How does the front-end work? How does the JSP actually handle the chat? Do you use an Applet in some way? Is your front-end HTML simply making POST requests to the server when someone enters a chat (which, together with the session, identifies the user in some way)? Does your servlet, on receiving some message, broadcast it to all clients (and how does a client display it in a browser)? We need more architectual information.
If you create a Swing application, then it would be "standalone" in the sense that it would be decoupled and assume no web capability in order to communicate with your servlet. You probably wouldn't want to use JSP here, as its a server-side scripting language for user-agents such as a Browser, which will render the HTML (of course, you could use certain Swing compoents such as JTextArea which can render basic HTML).
Your servlet could be re-used, but your requests would need to be converted to HTTP by your Swing application to act as a HTTP client (and your Swing client would need to parse the reply from the servlet so it could update its client chat window).
It really depends on how you have created your client-server application. But the best route, in my opinion, would be to do everything your client does and "emulate" it in a Swing application using an API such the HTTPClient API by Apache - it is quite pleasant to work with. Your servlet will think your Swing Application is just another browser. Even better, your Swing Application user could chat to someone who is using a web browser (which is probably why you want to create it in the first place). The only issue here is what your servlet returns to the client (i.e. a chat message from another user), and how it returns it (e.g. by adding some attribute in a session variable).
Joined: Feb 03, 2005
Thank You, for your reply. I think this would be very helpful to me to do my work... Thank You once again..
One thing I want to tell you that right now I am studying the tutorial about "HTTP TUNNLING" given at www.128ibm.com. It is a nice one and It will help me to do my project work.
I got you point that I have to generate the HTTP requests manually from my swing client.. and for Input-Output I have to use stream.. isn't it?
But I am coufused about the stream that which proper stream should be used to do the same..? I mean there are lots of streams provided by JAVA.
What are the other necessary changes that I have to do with my Swing application....?