473,387 Members | 1,844 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

HttpListener based app loading Java Applet into html page

Reg
I have a following code in HttpRequestListener's ProcessRequest method which
is a Windows
Console Application. I'm trying to read html page with browser (Opera) and
html file contains tags to include
Java Applet jar too,
for (int i = 0; i < numRequestsToBeHandled; i++)
{
HttpListenerResponse response = null;
try
{
// GetContext blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();
// Create the response.
response = context.Response;
int pos = context.Request.Url.AbsoluteUri.LastIndexOf("/");
string file = context.Request.Url.AbsoluteUri.Substring(++pos);
byte[] buffer = new byte[32768];
// Reading html and Java Applet Jar file from file system
FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read);
int read = stream.Read(buffer, 0, buffer.Length);
stream.Close();
response.ContentLength64 = buffer.Length;
System.IO.Stream output = response.OutputStream;
output.Write(buffer, 0, buffer.Length);
output.Close();

Problem is that I get "Invalid Bytecode" error in Opera and IE shows
nothing.

Something missing, can anyone tell me what?

Cheers,
Sep 4 '07 #1
1 2768
If the Html file contains tags to load the jar file, that's not what your
code is doing.
Your code:

int pos = context.Request.Url.AbsoluteUri.LastIndexOf("/");
string file = context.Request.Url.AbsoluteUri.Substring(++pos);

-- assumes that the request is directly for the jar file alone. What you
really need to be doing is serving the Html file that the request is asking
for, then you would get a subrequest from the browser reading the jar file
and you would need to serve that.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"Reg" wrote:
I have a following code in HttpRequestListener's ProcessRequest method which
is a Windows
Console Application. I'm trying to read html page with browser (Opera) and
html file contains tags to include
Java Applet jar too,
for (int i = 0; i < numRequestsToBeHandled; i++)
{
HttpListenerResponse response = null;
try
{
// GetContext blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();
// Create the response.
response = context.Response;
int pos = context.Request.Url.AbsoluteUri.LastIndexOf("/");
string file = context.Request.Url.AbsoluteUri.Substring(++pos);
byte[] buffer = new byte[32768];
// Reading html and Java Applet Jar file from file system
FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read);
int read = stream.Read(buffer, 0, buffer.Length);
stream.Close();
response.ContentLength64 = buffer.Length;
System.IO.Stream output = response.OutputStream;
output.Write(buffer, 0, buffer.Length);
output.Close();

Problem is that I get "Invalid Bytecode" error in Opera and IE shows
nothing.

Something missing, can anyone tell me what?

Cheers,
Sep 5 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob | last post by:
Hi, Me big time java newbie, in fact I'm currently downoading the plugin for Xp. I have no dramas with OO concepts, polymorphism and library classes and the concept of extending Applet, I was...
0
by: travisGatesMcGee | last post by:
Need to extract collection of links, images, etc from a web page in VB.NET It used to be sooooooooooooo easy before .NET, ie. Set oE = CreateObject(gsExp): oE.Visible = True: oE.navigate...
1
by: rajbala.3399 | last post by:
Hi all, I have the netbeans IDE5.5 in my system and redhat9.While i run my plugin or beans program in JSP the output you see an image that looks like a small white box with a Red X in it. Or, the...
3
by: hmmm | last post by:
I am a user, not a programmer. I arrived at this site because, while researching my problem, someone with a similar problem was referred here. IE 7 Windows XP Pro SP2, all critical updates as...
3
by: Jimbo | last post by:
I have a website & applet produced under Windows-XP. It works fine. I took it to a machine running Windows 98 & an earlier version of Java to test what happens when I open the web page using IE6 &...
0
by: Reg | last post by:
I have a following code in HttpRequestListener's ProcessRequest method which is a Windows Console Application. I'm trying to read html page with browser (Opera) and html file contains tags to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.