Solved

java streams to web page possible?

Posted on 1998-10-20
6
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
What You Need to Know when Searching for a Webhost Provider
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

740 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