Trouble embedding Java applet into an html page - java

I currently have a relatively simple Java applet which I am trying to embed into an html page. I've looked around, and haven't found a suitable answer. Many answers refer to using the deprecated <applet> tag, and the rest do not seem to work for me.
This is the body of my page. I initially tried using the <applet> tag and it worked, however I was unable to get it to use the full height of the page, and then I found it is deprecated anyways.
I've tried this on Firefox, Chrome, and IE, and it won't work on any of them. It only shows the alternative text.
I did read that the <object> tag only works for IE, but even so it isn't working for me. Likewise, most of the information I found is outdated.
<body>
<object width="500" height="500" data="project">Your browser does not support the <code>object</code> tag.
</object>
</body>

Ive had no problems using the applet tag to get applets to display to a desired width and height. All the Java resources point to using the same tags. I'm no html guru though, so I'm not sure if there's another solution.
<applet code= "myJavaApplet.class" width="600" height="700">textgoeshere</applet>

Related

jsp:include gives 404 when running

My directory tree is like this,
- /index.jsp
- /template/topHeader.jsp
- /accounts/signin.jsp
In my index.jsp I have included the topHeader.jsp like this,
<jsp:include page="template/topHeader.jsp" />
This works fine without any problem. But in the topHeader.jsp I have some <a> tags which I have given paths,
<div class="pull-left">
Hello! Sign in.
</div>
After running, this link gives a 404 which is understandable because the index page is already in the root folder. Now in the future I may have to include this topHeader.jsp almost everywhere.
Browser changes the url like this,
localhost:8084/project/index.jsp
after clicking on the sign in (404)
localhost:8084/accounts/signin.jsp
but the path should be
localhost:8084/project/accounts/signin.jsp
I have also tried including the topHeader.jsp in the following way, but got the same results.
<%# include file="template/topHeader.jsp" %>
So what is the easiest way to give the paths to <a> tags. I'm sorry the question may seem a bit unclear but I don't know how to explain it better.
Use ${pageContext.request.contextPath} to give relative paths to the links,
Sign in

How to properly incorporate applets on HTML page?

I have been trying to incorporate my simple Java applet on a HTML page, but I haven't found any luck getting it to work. I have done some research on the matter and I have found some contradictory results.
My understanding is the tags <applet></applet> have been deprecated. I went to one site and I read that I needed to use the <embed></embed> tag. Then I went to another site and read that I needed <object></object> tags. Problem is I have used both of the tags <embed> and <object>, but I haven't succeed in incorporating my applet on my HTML page.
I am using the Eclipse Juno IDE for the java applet and Notepad++ for the HTML page.
<embed width = "60" height = "60" type = "application/x-java-applet;jpi-version=1.7.0" code = "SimpleApplet.class" > </embed>
<object width = "60" height = "60" classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" >
<PARAM name="code" value="SimpleApplet.class">
</object>
The best way to deploy a JWS app. or applet is to use the Deployment Toolkit Script. It will use whatever tag is most appropriate for that version of that browser.

Can't get all content from webpage with HTMLParser

I am using Jsoup to parse an webpage this one https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=true&multiple=true&allEx=true
In that webpage i can see something in the browser but when i am trying to parse it with Jsoup
Document doc = Jsoup.parse("https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=true&multiple=true&allEx=true");
System.out.println(doc);
It will return
<html>
<head></head>
<body>
https://daisy.dsv.su.se/servlet/schema.MomentInfoRuta?id=261020&kind=100&nochange=true&allPrio=trueμltiple=true&allEx=true
</body>
</html>
Which is not all HTML.
Any suggestions how i can solve it or why it is happening?
That looks like they're detecting a crawler, usually via your user agent, and sending different content. Try setting your user agent string to a standard browser's string, and see if that resolves the issue you're having.
One other potential problem, though I don't think it's the issue here, is data loaded in via AJAX will not be downloaded by JSoup. It parses the HTML that gets served up, but it doesn't execute the JavaScript, so it can't get any extra content that comes in later. You might be able to resolve that issue using something like PhantomJS which can process and render HTML, CSS, and JavaScript, and would (in theory) give you the actual HTML you end up seeing in your browser.

Display an applet in a webpage using HTML/JavaScript

I have very little experience with HTML and applets. I have tried several of the things I found online, but am unable to make my Java applet run in a web browser (it functions in eclipse).
I have put the HTML file in the same folder as all of my Java class files for the applet. I am currently using Safari, but would like the applet to work in most any popular browser.
How can I display a java applet on a webpage using HTML/JavaScript? Can anyone offer any tips/advice?
Below is my attempted HTML code.
Attempt 1:
<Html>
<Head>
<Title>Pendulum Applet</Title>
</Head>
<Body>
<br>
<br>
<embed code="PendulumApplet.class"
width="200" height="200"
type="application/x-java-applet;version=1.5.0"
pluginspage="http://java.sun.com/j2se/1.5.0/download.html"/></embed>
</Body>
</Html>
Attempt 2:
<Html>
<Head>
<Title>Pendulum Applet</Title>
</Head>
<Body>
<br>
<br>
<OBJECT
classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
width="200" height="200">
<PARAM name="code" value="Applet1.class">
</OBJECT>
</Body>
</Html>
Try below code
<APPLET CODE=AppletSubclass.class WIDTH=anInt HEIGHT=anInt>
</APPLET>
OR
<object width="400" height="400" data="helloworld.class"></object>
Good Luck...
Use deployJava.js to write the applet element. The script is supported by Oracle, and will:
Check the user has the minimum required Java, prompting them to install if not, before..
Writing the object/embed or applet element as is best known for that browser.
Other notes:
Is it PendulumApplet.class or Applet1.class? It is hard enough to debug problems on international forums without introducing doubt about the name of the applet class.
The .class extension in the code attribute is tolerated, but not correct. The value should be a string representing the Fully Qualified Name of the class. E.G. javax.swing.JApplet as opposed to javax.swing.JApplet.class.
HTML element names should be all lower case (e.g. <html> as opposed to <Html>)
What output do you see in the Java console? When debugging applets in a browser, it is vital ensure the Java Control Panel is configured to pop open the console on discovering an applet (or JWS app.).
Although I have not done so myself, my Java textbook provides this outline for an embed:
<applet
code = "ClassName.class"
width = 250
height = 50
[archive = archivefile]
[vspace = vertical_margin]
[hspace = horz_margin]
[algin = applet_alignment]
[alt = alt_text]
>
</applet>
(Optional parameters in brackets)
I was having this SAME issue myself.
Using <applet code=""></applet> doesn't work, but <Applet> or <APPLET> seems to work.
Google Chrome and IE.

Java Applets and html page - embedding multiple applets

I have just started to write applets and so have never embedded in a webpage before. I have 2 applets that on there own run fine however when I try to run the 2 applets in the same page only one is visible. This seems very strange I have tried using the opening and closing foo bar tags for each applet.
These applets have no connection to each other however I also found that the html tags were also ignored after the applet which threw the page design out as well, this has totally baffled me.
The code encasing the applets is
<div class="wholeframe">
<div class="lframe3">
<!-- content for left frame to go here -->
<h2>Basic Java Swing Applet</h2>
<br />
<applet code="org.my.form1.MyApplet" archive="java/form1gui/FormApplet1.jar"
height="60" width="250"/>
</div>
<div class="rframe">
<h2>Basic Java Swing Applet</h2>
<applet code="org.me.hello.MyApplet" archive="java/hello/HelloApplet.jar"
width="350" height="150" />
<!-- right frame div end -->
</div> <!-- whole frame to box 2 frames -->
I would be grateful if someone could advise where I have gone wrong as this should be simple to do and I am sure it is but I cannot seem to work out the issue.
The first thing I'd recommend is validating that 'HTML' with the W3C mark-up validation service. The reason I put the HTML in commas is because whatever that mess is pretending to be, it is not (valid) HTML.
(grumbles) Programmers tend to think that whatever rubbish they put in HTML should work. The real world is somewhat removed from this fantasy land.
Other recommendations:
Post a link to the applet, broken or otherwise. If we are feeling motivated, we can visit it, look at the (entire) HTML, download the Jars or classes, and test solutions.
Ensure the Java Console is opened automatically when loading applets. Without the console information, you are debugging this with 'one arm tied behind your back'.
While debugging, reduce the web page to the minimum. No headers, divs, code, CSS etc. Include that stuff once it is working.
To embed more than one applet in a single web page, put each applet in its own subfolder within the folder that contains the HTML document. Use the APPLET tag's CODEBASE attribute to specify the folder that contains the applet.
For example, to embed the applets 'Aplt1' and 'Aplt2' in the web page defined by the file TestAplt.html, you can set up the following files and subfolders in a folder named Test:
Test/TestAplt.html
Test/Aplt1/<Class files for Aplt1>
Test/Aplt2/<Class files for Aplt2>
For files in this structure, put the following APPLET tags in the file TestAplt.html:
<applet codebase="Aplt1/" code=Aplt1 width=16 height=400 align="left">
<param name=ParamAplt1 value="Aplt1.djr">
</applet>
<applet codebase="Aplt2/" code=Aplt2 width=32 height=400 align="right">
<param name=ParamAplt2 value="Aplt2.djr">
</applet>
Please use this link Multiple applets in a page

Categories