File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Applets and the fly likes Applet and XML Doc through a browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet and XML Doc through a browser" Watch "Applet and XML Doc through a browser" New topic
Author

Applet and XML Doc through a browser

binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi Every body,

The task assigned to me is something like this. I have read the contents of an XML document and display the contents on the webpage. I chose applet for doing this task. I had successfully created a class which will read XML doc and an applet for display the contents one by one. When viewed in the applet viewer everthing is working fine.

But when started viewing the same in a browser after adding the code for viewing the same through an html / jsp file. I do not see the same output as viewed through an applet veiwer.

Then i thought the issue may be of calling the other classes required for execution of the applet (XML reader Class), then i transfered the code for reading the XML file inside the applet itself with out any joy.

Presently the .class file, the html, XML file and the jsp are in the same location. The XML file is in the server location and i am using URL and input stream for getting the file from the server to applet

The follwing are the codes as it is in my test condition

Mixed.Java


This is code for the html file



This is the code for jsp file



The Java console output is some thing like this



Your guidance would be of immense help to me.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18150
    
    8

binu narayanan wrote:I do not see the same output as viewed through an applet veiwer.


This appears to be the entire description of your problem. (If there was more buried in that dump of code, I apologize for overlooking it.) Could you possibly expand it into something which tells us what the problem is?
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi every body,

When i run the applet in applet viewer, iam able to see the output as it should be i.e. i get the see the output from the xml file in the applet. But while i run the applet in the browser be it Internet eplorer or Mozilla i do not get the output from the XML but get to see the panels and buttons which are available in the applet.

I hope your guidance could solve the issue.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18150
    
    8

I see. So the applet does appear, and the GUI looks normal? Is there a button which you click to display the XML document? If so, then what happens when you click it?

(I'm asking these questions because I haven't really read your code. All of the apparent code which turned out to be comments was very distracting, and the random indenting of lines was distracting too.)

Anyway, does the Java console have error messages in it when that happens? The usual problem with beginners to applet writing is that they don't realize that a File object refers to a file on the system where the applet is running and not to a file on the server where the applet was downloaded from. I did see a reference to a File in your code, then I saw it was commented out.
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi Paul,

I hope you are not offend by this addressing.

When the applet appears be it in applet viewer or in the browser i click on a button labeled start-- button name is btnStart. upon its click i start the XML read operation and set the textbox value to the value obtained from the XML. Moreover i have an image in the xml in the binary format which also gets displayed.

This is basic opertaion i intend to do.

While these are happening in the applet viewer. The same result is not achieved in the browser.

You are correct in pointing out , i had initially used the file option to get the XML doc, which will not server the purpose while renderig through a browser.

I am sorry about the codes i had postednot in a formatted way.

Your further help will surely sail me through this
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi Paul,

The following is the out put in the Java Console

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18150
    
    8

binu narayanan wrote:While these are happening in the applet viewer. The same result is not achieved in the browser.


That isn't much help. If you want help with your problem you need to provide a description of the problem. All we know so far is what didn't happen. That leaves open the question of what did happen instead, which is important information.
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi Paul,

I had explained what happens, like i have a start and stop button. The start button initiates the process opf reading a XML and displaying the contents to the applet.

I am attaching two screen shots to show what happens when the start button is clicked in the applet viewer and the browser


Binu



[Thumbnail for browseroutput.jpg]


[Thumbnail for appletoutput.jpg]

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18150
    
    8

I see this is an Applet and not a JApplet. Why?
binu narayanan
Ranch Hand

Joined: Jul 24, 2009
Posts: 56
Hi Paul,

Does having this in Japplet carry any added advantage. Kindly enumerate.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet and XML Doc through a browser
 
Similar Threads
applet not loading
problem with JPanel / JLabel zooming
Applet not inited message in JSP... what may be the reason
grid bag panels overlap : please HELP if you can
Argh....all I want to do is load this applet..