Click here to Skip to main content
15,922,155 members
Home / Discussions / Java
   

Java

 
QuestionHow can I rename an existing Spring MVC maven project Pin
Stephen Holdorf10-Nov-15 12:44
Stephen Holdorf10-Nov-15 12:44 
AnswerRe: How can I rename an existing Spring MVC maven project Pin
Stephen Holdorf10-Nov-15 12:55
Stephen Holdorf10-Nov-15 12:55 
QuestionHow do I add multiple Spring MVC controllers to my maven project Pin
Stephen Holdorf9-Nov-15 13:29
Stephen Holdorf9-Nov-15 13:29 
QuestionSince i m a student can I get industrial level examples on java where inheritance is major part? Pin
SSHASHIDHAR5-Nov-15 1:10
SSHASHIDHAR5-Nov-15 1:10 
AnswerRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
OriginalGriff5-Nov-15 1:13
mveOriginalGriff5-Nov-15 1:13 
GeneralRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
SSHASHIDHAR5-Nov-15 1:22
SSHASHIDHAR5-Nov-15 1:22 
QuestionRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
SSHASHIDHAR5-Nov-15 1:45
SSHASHIDHAR5-Nov-15 1:45 
AnswerRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
Richard MacCutchan5-Nov-15 5:39
mveRichard MacCutchan5-Nov-15 5:39 
GeneralRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
SSHASHIDHAR5-Nov-15 9:29
SSHASHIDHAR5-Nov-15 9:29 
GeneralRe: Since i m a student can I get industrial level examples on java where inheritance is major part? Pin
Richard MacCutchan5-Nov-15 23:12
mveRichard MacCutchan5-Nov-15 23:12 
QuestionNewly added jap page requested resource is not available Pin
Stephen Holdorf3-Nov-15 7:38
Stephen Holdorf3-Nov-15 7:38 
AnswerRe: Newly added jap page requested resource is not available Pin
Stephen Holdorf3-Nov-15 7:58
Stephen Holdorf3-Nov-15 7:58 
QuestionCode Design alternative for a Turn based game Pin
sitnik3-Nov-15 0:16
sitnik3-Nov-15 0:16 
QuestionHow do I Manually adding Spring MVC import libraries in to a Controller file Pin
Stephen Holdorf30-Oct-15 10:24
Stephen Holdorf30-Oct-15 10:24 
AnswerRe: How do I Manually adding Spring MVC import libraries in to a Controller file Pin
Richard MacCutchan30-Oct-15 22:57
mveRichard MacCutchan30-Oct-15 22:57 
QuestionMessage Removed Pin
29-Oct-15 13:53
Stephen Holdorf29-Oct-15 13:53 
NewsA new java open source framework: BabyFish Pin
babyfish-ct29-Oct-15 7:32
babyfish-ct29-Oct-15 7:32 
Questionjsp Pin
mohanbc1827-Oct-15 23:29
mohanbc1827-Oct-15 23:29 
GeneralRe: jsp Pin
Richard MacCutchan27-Oct-15 23:36
mveRichard MacCutchan27-Oct-15 23:36 
AnswerRe: jsp Pin
mohanbc1827-Oct-15 23:42
mohanbc1827-Oct-15 23:42 
GeneralRe: jsp Pin
Richard MacCutchan28-Oct-15 0:31
mveRichard MacCutchan28-Oct-15 0:31 
GeneralJava or JavaScript AKA where to start Pin
Vaclav_27-Oct-15 5:03
Vaclav_27-Oct-15 5:03 
GeneralRe: Java or JavaScript AKA where to start Pin
Richard MacCutchan27-Oct-15 5:26
mveRichard MacCutchan27-Oct-15 5:26 
GeneralRe: Java or JavaScript AKA where to start Pin
Vaclav_27-Oct-15 16:11
Vaclav_27-Oct-15 16:11 
QuestionJava RMI - chat app Pin
dzstef24-Oct-15 8:14
dzstef24-Oct-15 8:14 
XML
Hi everyone,
I would be grateful if someone help me with next problem that i have in Java:
Thing that i want to do is to make client-server chat app on web. I am using RMI. I will show just important class for my problem..
Here is mu server interface:

<pre lang="java">public interface ChatServerIF extends Remote {
//void registerChatClient(ChatClientIF chatClient) throws RemoteException;
//void broadcastMessage(String message) throws RemoteException;
void registerClient(String ime, ChatClientIF chatKlijent) throws RemoteException;
void posaljiPoruku(String ime, String poruka) throws RemoteException;
void dodajWeb(String naziv, PrintWriter print) throws RemoteException;
void pronadjiWeb(String naziv) throws RemoteException;
}


server class:

Java
public class ChatServer extends UnicastRemoteObject implements ChatServerIF {
public static final long serialVersionUID = 1L;
private HashMap<String, ChatClientIF> hmap = new HashMap<String, ChatClientIF>();
private Map<String, PrintWriter> web = new HashMap<String, PrintWriter>();
public List<HttpServletResponse> lista = new ArrayList<HttpServletResponse>();
public ChatServer() throws RemoteException{
//chatClients = new ArrayList<ChatClientIF>();
}
@Override
public synchronized void dodajWeb(String naziv, PrintWriter print) throws RemoteException{
web.put(naziv, print);
}
@Override
public void pronadjiWeb(String naziv) throws RemoteException {
//JspWriter pisi = web.get(naziv);
}


and part of servlet:

Java
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet IgraServlet</title>");
out.println("</head>");
out.println("<body>");
String username = request.getParameter("username");
ChatServerIF chat = (ChatServerIF) request.getSession().getAttribute("server");
ChatClient cc = (ChatClient) request.getSession().getAttribute("klijent");
//ChatServer cs = (ChatServer) request.getSession().getAttribute("cs");
PrintWriter pw = (PrintWriter) request.getSession().getAttribute("out");
chat.dodajWeb(username, pw);
cc.run();
out.println("aaa");

out.println("<h1>Servlet IgraServlet at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}


My idea is to store user and PrintWritter for that user, from web page on server in order i can later sent message to that client.
Am i thinking good, or completely wrong?

But problem comes when i call chatServer interface method on servlet "chat.dodajWeb(username, pw)" i got next error:
java.rmi.MarshalException: error marshalling arguments; nested exception is:
java.io.NotSerializableException: java.io.PrintWriter
Please help me i try to search solution on internet, but for now without result..

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.