Solved

java streams to web page possible?

Posted on 1998-10-20
6
191 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jar file executable 12 58
Help with a redirect in web.config file 8 56
hibernate example issues from command prompt 10 50
jmss example java 2 23
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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …

790 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