Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

chat application  RSS feed

 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to create chat application using Servlets & JSP. May I know how I can create a chat application , as I have never created before?

How much knowledge I need to have to create chat application?

Is there any need of networking API to create chat application?

What's the design pattern I need to follow to create that application?

Is there any need of database?







 
Balaji Vankadaru
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Database is needed if you want to persist user details. If you do not intend to persist any details then jsp and servlets serves your requirement. Using any open source ui would be a better deal to have very cleaner and better maintainable code. I would suggest jsf2.0 would be a wise option as per me.

A normal chat application would have certain features like sending a private message or smileys or blocking a person.

To meet this kind of requirement you need Listeners. Action listeners and Event Listeners can be used to serve the purpose.

Few Implementations need to be taken by us if we intend to develop web application using plan servlets and jsp like front controller, composite view, view helper, service to worker and dispatcher view.


 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Important! Before writing ANY code - get a whiteboard or lots of paper and diagram out how data will move around the system and all of the states a user might find themselves in.

Look at this wikipedia article on Use Cases and glance over this article on UML.

2. Do not make any assumptions about database, design patterns or toolkits until you have the requirements worked out!

Bill

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are building the chat application as an exercise or it is your job?
If it is your job, you might want to consider using Netty, Vert.x or Node.js . With Netty you can write high performance client & server endpoints. Really convenient for chat applications.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is way too early to talk about this kind of implementation detail. Start by nailing down what exactly it is you intend to do. If you haven't used chat before, start by playing around with a few different chat apps so that you get a feeling for what they do, and what you might like to implement.

As regards Balaji's recommendation of JSF, that is very unlikely to be a good choice, since the UI part of a chat app is the smallest piece of it. The details of communication are much more important, and that will likely be done by JSON over REST, or maybe WebSockets if you want to be on the cutting edge. What's more, JSF has a non-trivial learning curve, and since it sounds like you're just starting out with web apps, you may want to postpone learning big frameworks.

I also disagree with the statement "Using any open source ui would be a better deal to have very cleaner and better maintainable code." - open source code can be as good or as crappy as any other code.

As an aside, I think a chat app is not a good project to tackle if you want to learn to write web apps; but that is of course up to you.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Balaji Vankadaru wrote:Database is needed if you want to persist user details. If you do not intend to persist any details then jsp and servlets serves your requirement. Using any open source ui would be a better deal to have very cleaner and better maintainable code. I would suggest jsf2.0 would be a wise option as per me.

A normal chat application would have certain features like sending a private message or smileys or blocking a person.

To meet this kind of requirement you need Listeners. Action listeners and Event Listeners can be used to serve the purpose.

Few Implementations need to be taken by us if we intend to develop web application using plan servlets and jsp like front controller, composite view, view helper, service to worker and dispatcher view.




first of all how do i connect to the other computer for chat..???what is the basic code to connect to the other computer.please tell me..
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You want to code Peer2Peer chat application?
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hussein Baghdadi wrote:You are building the chat application as an exercise or it is your job?
If it is your job, you might want to consider using Netty, Vert.x or Node.js . With Netty you can write high performance client & server endpoints. Really convenient for chat applications.



its my exercise but what is this netty or vertx?i would like to use them..i am not understanding how to start with..i know my design but how do i connect to the other computer to chat with that person?which api should i use..Please tell me the basic code
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hussein Baghdadi wrote:You want to code Peer2Peer chat application?



no ..i mean like the other chat sites on the internet..multiple users chat application..
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
At this point, I would say stop doing anything and read Java Networking.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hussein Baghdadi wrote:At this point, I would say stop doing anything and read Java Networking.


do i have to use networking api for web based chat applications..???..i read ..but practically how to use it and when and where i am not understanding..please tell me..cant i prepare a chat application without networking api?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any time two machines exchange traffic over a network, there's networking involved, so there's no way to avoid it. What do you think "networking" means?

But since you post in the "Servlets" forum I take it you want to write a browser-based chat client - that would mean HTTP from within JavaScript, or maybe WebSockets as I mentioned - in both cases the Java networking stuff Hussein linked to wouldn't be applicable, atleast not on the client.

But you would have to create a server that accepts requests from the browser, and can react to them in an intelligent fashion. A servlet container is one way, but as Hussein pointed out, there are other options.

So, I hope that your design is not finished, as you say, because there seems to be a great deal still left to be decided. As both William and myself said earlier, start by determining the requirements.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
question 1. so i have to create a chat server and client...before posting it on the internet???

question 2. i know how to create a server and a client socket and communicate between them.This is from one server to one client and i used java.net packege.But now i want to create a chat site where multiple users communicate and place it in the internet.For this what api's should i use??

question 3. what is the difference between sockets and websockets?.Where can i get websockets api because it is not avialable in java api.?should i use websockets for my requirement?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
#1 - Not sure what you mean by "posting it on the internet", but yes - chat is almost exclusively done by having the clients be intermediated by a server. So you need both parts.

#2 - The classes in java.net are fine if you intend to create a Java client - do you? If you intend to create a browser client, then the java.net classes are not an option (unless you're talking about an applet client).

#3 - WebSockets are a newish thing for use with JavaScript within browsers. Very few browsers support it at this point. The server side could be handled by a JEE 7 server.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to do a chat application project.Please tell me in detail what steps should i take from the start.I am confused.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please drop the habit of quoting entire posts. Quoting is for extracting specific bits of a post that you intend to reference in your response. Otherwise it makes no sense.

so you mean that i should use JEE HTTP package for coding brouser client and server? ... kindly give me answers for my above queries so that i can understand how to code.

Not sure what you mean by "JEE HTTP package", but JEE is what would be running on the server - it has no bearing on your choice of client. If you decide to use an applet as the client, then you would be using JSE for that.

can anyone please tell me what packages to be used for creating a web based chat server and browser client???

You're way too focused on implementation details at this point. It has been mentioned multiple times that you need to start thinking about what you want to build (the requirements), and then comes the architecture (like what kind of client, what kind of server, how do they communicate, etc.). Only then does it make sense to think about details like packages or libraries to use.

i am using weblogic server, so which version should i use for websockets?

A version that supports JEE 7. I doubt that WebLogic supports it yet, but there may be a way to add WebSockets support to an older WL version. That's a separate question you should ask in the WL forum.

as you said that very few browsers that support websockets ,what is the alternative?what was used before websockets?is using javax.servlet.http package enough?

Plain old HTTP, with servlets on the server side is a possibility.

from where can i download jee 7 specification?

Bookmark this page, you will need it many times in the future: https://www.coderanch.com/how-to/java/SpecificationUrls

if not websockets ,which specification should i use?

Not quite sure what you're asking here. Using HTTP is a possibility.

My impression is that you're not knowledgeable enough about networking at this point to make sound decisions about how to architect and implement such a project. I would suggest you start by coding a "normal" web app, learn about HTTP , browsers and web servers in the process, and maybe add a JavaScript library like jQuery after that for some in-page updates. Then you should be able to appreciate the challenges of what you propose to do. I suggest leaving cutting-edge stuff like WebSockets out altogether.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to do a chat application project.Please tell me in detail what i should do and from where i should start.I am confused.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think I can help you if you expect to be spoonfed every step along the way; that's way too much to expect. I have already given the best advice I can: #1, start with something that is within reach and build your way up from that, and #2, start by thinking about what exactly it is you want to build, then architect it, and only then start thinking about implementation details. If that overwhelms you, go back to #1. Good luck.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok.Thankyou.
 
puja dayal
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



getting compilation error at this point 'serversocket.close();' unreachable statement
 
Ivan Jozsef Balazs
Rancher
Posts: 992
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inside the try block there is an endless loop: the only escape is through an exception.
In the catch block you do a System.exit - no way beyond that.
A non-caught exception would "blow" the method - that point is really not reachable.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!