Solved

java streams to web page possible?

Posted on 1998-10-20
6
188 Views
Last Modified: 2013-11-21
Is it possible to use Java to dynamically send streams of info to construct a web page real time?

In other words, instead of constructing an html doc file with java and then loading that into the browser, can I send the html constructs directly to the browser as a stream of data?
0
Comment
Question by:rutledgj
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1226008
In Netscape it is quite easy:
(example from JavaScript the definitive guide 3rd)

JSObject jsroot = JSObject.getWindow(this);
jsroot.eval("top.frames[1].document.open()");
jsroot.eval("top.frames[1].document.write('Hello from Java')");
jsroot.eval("top.frames[1].document.close()");

THe Hello from Java can of course be any string you have already created.

To do the same in IE, you will need to deconstruct the Netscape JSObject and pack it with your applet.

Michel
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1226009
PS: You will need point your classpath to .....Netscape/.../java.../ when you compile your applet,
and the applet tag needs to include the MAYSCRIPT attribute:
<APPLET .......... MAYSCRIPT>

Michel
0
 
LVL 4

Expert Comment

by:seguret
ID: 1226010
If you mean write a server in java that dynamicly constructs web pages, Yes, it's easy. You can do this with servlets. Of course, if you don't include javascript in your pages, every browser can be used.
0
Scale it in WD Gold

With up to ten times the workload capacity of desktop drives, WD Gold hard drives employ advanced technology to deliver among the best in reliability, capacity, power efficiency and performance.

 

Author Comment

by:rutledgj
ID: 1226011
I think seguret's answer is more on track of what I was thinking. I don't want to have to depend on JavaScript, just plain Java. Can this servlet act as a CGI program? Lets say I have a form on my html page. When I submit I want my java program (CGI program?) to evaluate the info and dynamically construct a new html response by outputing some type of stream to the browser. I don't know how to do this. Using servlets?
0
 
LVL 4

Accepted Solution

by:
seguret earned 50 total points
ID: 1226012
It's better to use servlets if you're needing multi-threading, request analyse, remote administration, or if you want to place your program by an internet provider (some providers accept them and consider thy're more secure than CGI).
But servlets have problems : they're difficult to debug (all serious servlet servers have their own class loader), servlet servers are often (all?) buggy. It's not adapted to very big applications.
If you want to make something very simple (like a counter), you may use a small code of your own, it's not so hard (I wrote it) because the HTTP protocol is simple. In this case you won't need any piece of software other than your VM.
The third option is to use another service server (I mean not written upon the servlet standard). We wrote such a program in my company(INGENIA). But that's a big developpement.
Today, there are two serious (they even offer SSL) servlet servers:
 - the one of Sun, Java Web Server.
 - JRUN, from LiveSoftware

P.S. If you want I to write a simple dynamic web-server (no multi-thread, no session, no nothing but some indications on how to add them and no need of any other software), upgrade your question to 'hard' and I'll take the time to do it.

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1226013
Any server based program in any language that can be run from a command line on the web server's platform can create html on the fly using cgi conventions. Java is not imperative - even dos BAT files can create html. Just a matter of sending
Content-type: text/html
plus two carriage returns plus any html you want.

When you asked about Java, I thought you wanted an applet to write html it had created to a frame in the browser.

Michel
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now