Solved

java streams to web page possible?

Posted on 1998-10-20
6
190 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference of if loops 23 49
spring jars download 1 27
mysql jsp example issue 32 33
going to wrong jsp page 2 20
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

776 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