473,653 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HttpListener based app loading Java Applet into html page

Reg
I have a following code in HttpRequestList ener'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 < numRequestsToBe Handled; i++)
{
HttpListenerRes ponse response = null;
try
{
// GetContext blocks while waiting for a request.
HttpListenerCon text context = listener.GetCon text();
// Create the response.
response = context.Respons e;
int pos = context.Request .Url.AbsoluteUr i.LastIndexOf("/");
string file = context.Request .Url.AbsoluteUr i.Substring(++p os);
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(buf fer, 0, buffer.Length);
stream.Close();
response.Conten tLength64 = buffer.Length;
System.IO.Strea m output = response.Output Stream;
output.Write(bu ffer, 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 2807
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.AbsoluteUr i.LastIndexOf("/");
string file = context.Request .Url.AbsoluteUr i.Substring(++p os);

-- 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 HttpRequestList ener'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 < numRequestsToBe Handled; i++)
{
HttpListenerRes ponse response = null;
try
{
// GetContext blocks while waiting for a request.
HttpListenerCon text context = listener.GetCon text();
// Create the response.
response = context.Respons e;
int pos = context.Request .Url.AbsoluteUr i.LastIndexOf("/");
string file = context.Request .Url.AbsoluteUr i.Substring(++p os);
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(buf fer, 0, buffer.Length);
stream.Close();
response.Conten tLength64 = buffer.Length;
System.IO.Strea m output = response.Output Stream;
output.Write(bu ffer, 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
2731
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 around java about ten years ago while at university, the concepts remain but the details are blurred as I haven't touched it sense and I do say unfortunately to that. Here's my question : can a java applet running in one frame pass data to a php...
0
1141
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 "www.msn.com" Do Until oE.readyState = 4 DoEvents loop Set oDoc = oE.document .....then explore the heck of the the html page
1
2769
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 browser cannot display the chat applet, and shows the error message "Loading Java Applet Failed...". I gone through the below sites and i tried each and every thing but it didn't work not only this no. of site to get solve but no use.
3
7252
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 of 11pm, 14 Feb 2007 java 1.5 11 before installing that, today, I uninstalled Java 1.5. 6 & 1.5. 10 ethernet connection I am trying to view the animation at www.time.gov
3
4377
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 & FireFox. The html invoking the applet is: <applet code="assumptions.class" archive="popproj.jar" width='760' height='340'> This applet was coded using Java 1.5.0_08-b03.</applet> Instead of the expected text, both browsers said "Loading Java...
0
1264
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 include Java Applet jar too, for (int i = 0; i < numRequestsToBeHandled; i++) { HttpListenerResponse response = null;
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4291
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2707
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.