Two Laptop Bag
The moose likes Java in General and the fly likes University Registration System Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "University Registration System" Watch "University Registration System" New topic
Author

University Registration System

Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
James and everyone else,
Perhaps you could help me solve a little problem I am having. I am designing a university registration system using Java (servlets & JSP, oracle). It is web-based, and because of this there's a slight problem. I need a way to refresh the page when the number of slots for a particular class changes. Otherwise, the number I am looking at on my screen will be off when someone at another terminal registers for that class. I know forced browser refreshes are impossible, but I was wondering if you guys had any bright ideas. I was thinking of having an applet for every "slots available number" and have that applet update itself when someone enlists (using RMI). Is this even possible? Any bright ideas?
Thanks for your help.
Shubhrajit Chatterjee
Ranch Hand

Joined: Aug 23, 2001
Posts: 356
The RMI route is possible, you need to use client side callback technique.

Shubhrajit
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Ok, so I can make call-backs to applets. But wouldn't that look ugly and be heavy on memory? Let's say the user were looking at a page with 50 classes. That would be 50 applets connected to an RMI server. Is this really feasible? Or are there any other ideas?
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
You could make a light RemoteScripting-esque applet interface between DHTML and a Servlet. Is DHTML an option? How 'bout one simple applet included many times on the page with different paramaters for differnet classes that just connects to a servlet and gets fed up-to-date info.
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
David Garland,
That seems interesting. What do you mean by applet connecting to a servlet? I didn't know this was possible. How does this work?
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
An applet can connect to the server it was downloaded from with the normal socket API. Probably the easiest method and least likely to cause trouble (because of firewalls or sandbox rules) is to use http tunneling.
Basically, you can create an HttpServlet at your site (let's say it's at http://mysite.com/servlets/CourseFeeder) that doesn't actually serve web content. Instead, it just takes the output/input stream it's given an uses it to communicate with a client.
The client in this case would be an applet. It could create a URLConnection to http://mysite.com/servlets/CourseFeeder and use URLConnection.getOutput/InputStream() to establish a normal TCP connection (you may have to call URLConnection.setDoOutput(true) first).
At this point the server and client are connected via normal TCP sockets. The applet could send a line formatted something like this: "FOLLOW SCI 234". Then it could constantly wait for input and to the applet.
The server would first wait for a command (a class name to follow) and then print the class initial size or an error message ("BAD CLASS" or "OK 26"). Whenever the data gets updated, the server could print another line ("OK 27").
Too bad nio isn't standard yet. You'd want a way for applet to say something like "DONE" and have the server close its connection, but this would require threads (a servlet no-no I believe) or awkward timeouts.
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Ok, thanks!!! I'll try that. Do you think there would be problems with let's say 50 of these small applets on a page? In your previous post you mentioned DHTML, where does this come in?
Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: University Registration System
 
Similar Threads
Problem in running swing applet in IE ...
Datagram lost in network
Problem in running swing applet in IE ...
Login action class using struts 2
Client Call Backs