I have create a simple Hello World Applet and I have save the .class file to the server where the JSP site is.
I want help so what I have to write in the JSP Site so whenever through the Browser I open this specific JSP Site this applet also run and show the message Hello world.
The JSP site and the .class file from the applet are at the same root, for example *D:\server\tomcat\test*
and also if someone can explain me what is the appletviewer and if I need something like this in my case?
You add an applet to an html page.
The jsp page gets compiled and when it runs its spits out html.
So in your browser all you will have is html.
So you basically need to embedd you applet to the html that is generated by your jsp page.
I would suggest you to do some research on adding your applet to html.
Once you have that, simply append the resulting html code (which has the applet) to your jsp page.
Embed the applet in the file by adding the following applet tag anywhere between the file's tags:
In an HTML file: <applet code="org.me.hello.MyApplet" archive="HelloApplet.jar"></applet>
In a JSP file: <applet code="org.me.hello.MyApplet" archive="HelloApplet.jar" width="600" height="480"/>
The jsp will ultimately spit out the html code.
Related
Basically I'm running some automated tests using TestNG.
I'm using ITestListener to give real-time results of my tests status but this is outputted to the console.
Is there anyway of outputting the information on the console to a HTML file so I can view the progress from the html file?
I'm planning to create a HTML style report for my own benefit so more specifically would it be possible to place to output to specific parts of the HTML Report I create?
Overall I'm trying to achieve is a HTML file that I can open on Chrome while my tests are running and with an automatic refresh I can view the progress of the tests.
I came up with a solution that uses a small amount of JavaScript to update your browser window:
Your major file would be:
<html>
<head>
<script>
function loadContentFile()
{
document.getElementById("content").innerHTML='<objecttype="type/html" data="content.html"></object>';
}
window.onload = setInterval(loadContentFile, 1000);
</script>
</head>
<body>
<div id="content"></div>
</body>
</html>
Edit:
Your Java program would write to a file called content.html. Just like you have done before. Nothing changes there. The "magic" happens by calling the index.html instead of the content.html. The index.html file when opened with a browser periodically loads the content of the content.html file thus realising a automatic reload of the page.
Conclusion: You have a folder containing the index.html and content.html.
Your browser calls the index.html. Your Java program writes to the content.html.
I have a requirement where i have to create widgets and display the source code on the web page to the user. The source code is jsp. But how can i stop executing jsp inside jsp page.
Is there any way?
Thanks.
How to see the which JSP file contains the given UI element like textbox in IE/Firebug Debugger?
Is there a way I can find out JSP file name? Even in firebug I don't see the jsp file name? In Internet Explorer debugger, when I do find select by element, it takes me to exact element source code. But it does not show
up JSP file name which contains this text box.
Say I am on any web page on internet explorer which contains some text box. I want to know the jsp file name which contains this text box.
JSPs are executed at server-side, and generate HTML. The browser doesn't know and doesn't care about the JSP. It goes to a URL, and takes the HTML from the response.
If you want to know which JSP generated some part of an HTML page, then discover to which servlet or JSP is the URL of the page mapped (provided this part is not generated by AJAX), and follow the path of the request from this servlet or JSP until you find the one that generates the given HTML part.
It can help to include a HTML comment at the start of every JSP, to be able to track that more easily:
<!-- Start of JSP foobar.jsp -->
This way, by looking at the HTML code, you just have to go up until you find such a comment to know which JSP generated it. But every JSP has to follow this rule.
Right click on page and select "ViewPageSource" from the menu.You can find the corresponding jsp.
I have a java applet that I would like to include in my ASP.NET page. The applet works on a regular old HTML page. When I try to include the applet in my ASP.NET page however, Java appears to start up (it shows the Java logo and the spinny blue circle), but an exception occurs for my main class:
load: class com.myclass.Main.class not found.
java.lang.ClassNotFoundException: com.myclass.Main.class
I am putting the applet in the page with the following code -
<applet
code="com.xyz.Main.class"
width="500" height="500"
archive="MyJar.jar"
>
<param name="aParam" value="SomeValue"/>
</applet>
Note, this is exactly the same tag that I use to put the applet into a plain HTML page. I'm guessing that the reason for the class not found exception is that when ASP compiles the page it puts it somewhere else? If so, where? Note that I still have not actually deployed this page to a web server, it's just running locally on my development machine.
Why not simply specify an absolute URI/oath to your applet with the codebase attribute? That way you would not have to worry about the vagaries of relative pathing of different systems.
Also see here for a longer explanation. Excerpt:
Specifying the Applet Directory
By default, a browser looks for an applet's class and archive files in the same directory as the HTML file that has the tag. (If the applet's class is in a package, then the browser uses the package name to construct a directory path underneath the HTML file's directory.) Sometimes, however, it's useful to put the applet's files somewhere else. You can use the CODEBASE attribute to tell the browser in which directory the applet's files are located:
<APPLET CODE=AppletSubclass.class CODEBASE=aURL
WIDTH=anInt HEIGHT=anInt>
</APPLET>
If aURL is a relative URL, then it's interpreted relative to the HTML document's location. By making aURL an absolute URL, you can load an applet from just about anywhere -- event from another HTTP server.
Create a simple Java Applet.
Create a default web application.
Copy the Applet.class file to the web application folder.
Add a default user control to the web application.
Add the following HTML code in the user control.
<applet name="applet" code="applet.class" width="640" height="480" archive="applet.jar"
> <param name="foreground" value="FFFFFF"/>
> <param name="background" value="008080"/>
> <param name="label" value="This string was passed from the HTML host."/> </applet>
Build and run the web application
And don't forget to add java.policy.applet.
cheers, :)
I am new to struts and I am not sure of jsp either. I am a php scripter with JS and C# experience and various other language including java but not the struts or jsp component.
I am confused as to how I can modify the html of a struts file once I have found the config in xml and the jsp linking to it.
JSPs are typically where you would look for HTML. So, you can usually just open the JSP and edit the HTML.
However, if the HTML is being generated dynamically, you may not see it there. There should be a Tag or Java Scriptlet that should give you some indication of where the HTML is coming from, though.