Solved

java streams to web page possible?

Posted on 1998-10-20
6
189 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
New! My Passport Wireless Pro Wi-Fi Mobile Storage

Portable wireless storage to offload, edit, and stream anywhere.

High-capacity, wireless mobile storage designed to accompany professional photographers and videographers in the field to easily offload, edit and stream captured photos and high-definition videos.

 

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

New My Cloud Pro Series - organize everything!

With space to keep virtually everything, the My Cloud Pro Series offers your team the network storage to edit, save and share production files from anywhere with an internet connection. Compatible with both Mac and PC, you're able to protect your content regardless of OS.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
compre toata in where clue oracle 4 56
VB Script to add site to Java Exception List 4 53
factorial example 4 35
tomcat not starting 6 31
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

920 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

16 Experts available now in Live!

Get 1:1 Help Now