I need to deploy an applet on a .jsp page and want to take advantage of lazy loading and pack200 that you get when using JNLP. However my client does not have the Next Gen Java Plugin enabled on their machines and they do not want to enable it. This means I can not take advantage of the jnlp_href attribute introduced in java 1.6.10.
After some research I discovered you can specify an applet-desc in my jnlp but I am new to JNLP and do not know how to fully take advantage of this tag.
I have not seen any solid examples of how to use a JNLP file on a webpage without using the applet or object tags which require the jnlp_href param attribute.
Is it possible using this applet-desc tag to inject a reference to my JNLP in my .jsp page?
Currently I specify my applet using the object HTML element like this:
<object code="<myappletClass>" name="pdfapplet" codebase="<myCodeBase>" mayscript>
<param name="jnlp_href" value="my-applet.jnlp"/>
</object>
However this does not grab the jnlp_href with Java plugin turned off in the Java console.
If the applet does not need to be embedded in the web page, it can be launched free-floating from the first versions of Java Web Start (available as a separate download around Java 1.2). It is only in the Next Generation JRE that a JWS deployed applet can remain embedded in a web page.
Related
I want to convert spring application into angular js. I am using some external css and js.
css is included properly but not js.
when I use
<script src="bower_components/angular/angular.min.js"></script>
It is considering angular.min.jsp and throwing error not found.
How to include external js into my app.
It seems as some misconfiguration on the server side.
I would suppose that you are using Apache 2.4 or Tomcat 7
In Apache 2.4 take a look at https://httpd.apache.org/docs/2.4/rewrite/remapping.html
If you were running the application in the ubuntu then default location to look at would be /etc/apache2 and usually this is going to be found in /etc/apache2/sites/available/000-default.conf
In Tomcat 7 take a look at
https://tomcat.apache.org/tomcat-8.0-doc/rewrite.html
Under Ubuntu with the default installation of Tomcat, this information will be found either in the file /var/lib/tomcat7/conf/server.xml or under the directory your application is deployed in META-INF/context.xml or under /var/lib/tomcat7/Catalina in one of the subdirectory. This depends a lot on the settings you have.
If neither of these is a case then take a look at the filters applied to the application as some of them can screw the answer. For them take a look at WEB-INF/web.xml or if you are using the XML-less configuration then try Some of the I believe SpringWebApplication classes.
If you still use the Spring to serve the backend then it is also possible that you have incorrectly set up ViewResolver, which returns .jsp as appendix instead of .js
I'm trying to wrap my mind around how to deploy a Java applet in my Laravel app.
To start with I'm just going to keep it simple and use the applet tag in a view:
<applet code="OHLib.class" width=0 height=0 />
(The applet contains just helper functions ... no UI, so I set width and height to 0. Will that work?)
When the browser requests that class from my web site, how to I serve it up? Do I define a route? I would like the java class to be located at www.mydomain.com/java/OHLib.class.
Deploy An Applet
Applets are deployed onto a web page via certain tags, which vary by browser, so the best thing to do is use a script provided by Oracle to inject the correct tag for you. I put the following code in a View so as to appear within the <body> tag. (It won't work in the <head> section.)
<script src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
id:'ohApplet',
code:'OHLib',
codebase: 'java',
archive: 'OHLib.jar',
width:1,
height:1,
} ;
var parameters = {
jnlp_href: 'OHLib.jnlp',
classloader_cache: 'false',
} ;
deployJava.runApplet(attributes, parameters, '1.6');
</script>
This will cause the browser to load OHLib.jar from the java folder. If the .jar file is in the same folder as the HTML document, you can skip the codebase attribute. See Deploying a Java Applet.
Serve An Applet
When the browser parses the injected tag, it will then make a request to the server for the Java applet, based on the 'archive' and 'codebase' attributes. So in my case I created a folder called 'java' under the Public folder, and placed the .jar file in there. Remember that your web app only gets invoked for URIs that don't exist on the server file system.
UPDATE:
I was able to add Vaadin 7 jars manually and create a v7 application but it still grave me the same error in the xml when I run it
I'm new to Vaadin and web application development. I'm still wrapping my head around all that is envolved in this technology and how it works.
I wanna develop a simple application with a login to do basic file parsing. I downloaded the Vaadin 6 eclipse plugin (I wasn't able to use version 7 because of newtork security). I'm using Tomcat 7, Eclipse Indigo Service Release 2, as well as Apache IvyDe plugin (which I still don't understand what it does!)
I used the dragDrop wizard in Vaadin to create the interface of my Login page but when I tried to run my program it it gave me the following error
The errors below were detected when validating the file "gwt-module.dtd" via the file "LoginWidgetset.gwt.xml".
In most cases these errors can be detected by validating "gwt-module.dtd" directly.
However it is possible that errors will only occur when gwt-module.dtd is validated in the context of LoginWidgetset.gwt.xml.
Line 2 - The markup declarations contained by the document type decleration must be well-formed
and there seem to be an error in the LoginWidgetset.gwt.xml which I couldn't reslove
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN"
"http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module>
<inherits name="com.vaadin.terminal.gwt.DefaultWidgetSet" />
<!--
Uncomment the following to compile the widgetset for one browser only.
This can reduce the GWT compilation time significantly when debugging.
The line should be commented out before deployment to production
environments.
Multiple browsers can be specified for GWT 1.7 as a comma separated
list. The supported user agents at the moment of writing were:
ie6,ie8,gecko,gecko1_8,safari,opera
The value gecko1_8 is used for Firefox 3 and later and safari is used for
webkit based browsers including Google Chrome.
-->
<set-property name="user.agent" value="gecko1_8"/>
</module>
I was also trying to use one of the Addons from the official Vaadin website but whenever I run my appliation it gives me the same error with the .gwt.xml
Does anybody know what's causing this error? It would also be very helpful if you could explain to me the role of the IvyDe plugin. I'm not using Maven but only because I don't know how it would help. If you could shed a light on that too I'd really appreciate it.
And on a final note, is this the right approach I should be taking to develop web apps or should I stick with common frameworks and jsp?
Thanks
The network security was blocking the google-web-toolkit.googlecode.com server so I created a gwt-module.dtd and stored it to a local directory and then referenced that in my xml instead of the live link.
<!DOCTYPE module
SYSTEM "file:\\\\public\share\MyWebApp\WebContent\WEB-INF\gwt-module.dtd">
Would it work to setup some filters using Spring 3 MVC where the paths for javascript files and css files are modified when streamed to the client, by embedding some timestamp in the filename. And then when those resources are later requested another filter then strips those timestamps out?
This would be an attempt to prevent problems of cached js/css files when an application is redeployed
What would I need to do to set this up? How do I setup the filter to replace the paths with a timestamp and then how to I setup the filter to later strp the timestamps out?
I just need info on the Spring 3 MVC configuration for it in the web.xml, I am ok with what the actual code in the filter will need to do
It may be simpler to use Spring's resource mapping <mvc:resources>, that maps a virtual path to the real location of your CSS and Javascript files. The virtual path can contain the version of your application. This means that when you deploy a new version of your application, the path of the CSS and Javascript that gets sent to the browser is different than before and this fools the browser into thinking that they're new resources - and so it reloads them.
For example to map CSS and Javascript files in /resources:
<mvc:resources location="/resources" mapping="/resources-1.2.0/**"/>
This says that any request that comes in with the URL pattern /resources-1.2.0 followed by anything (e.g. /resources-1.2.0/css/styles.css), look for the file in the folder named resources in the web root.
When you update the application version between deployments the virtual path to the CSS and Javascript resources will change and so browsers will be forced to reload the files - even though the real files are in the same old location.
You can make the application version dynamic too - so you don't need to modify your config file.
There's a more in-depth write up of this whole approach here.
I have an application which is invoked via Java Webstart. Opening it via the Webstart link works without any issue.
I also have an application based on Excel that generates files (via vba) which can then be opened by the program that starts via Webstart.
What I would like to do is have a button that invokes the Webstart application and then opens a newly generated file. The files name (and contents) are time sensitive and so I can't use the same file name over and over.
I've pretty much figured out how to use vba to invoke the application via Webstart but the problem is that for the Webstart app to be able to open a file it needs to be passed in as an argument in the jnlp descriptor
<application-desc main-class="com.foo.WebstartApp">
<argument>-file</argument>
<argument>C:\files\file_20100909_164834.csv</argument>
</application-desc>
How do you go about passing through the filename into the JNLP file when the filename will always be different?
Should I be looking at dynamically generating a new jnlp file each time, or is there a way to parameterize the jnlp file and pass through the filename when invoking the JNLP?
Dynamically generated JNLP files is probably going to open you up to injection attacks, just like dynamic SQL. Further it looks as if you are expecting the user to trust the WebStart application which trusts the JNLP file which is untrustworthy.
Assuming you have one application instance per desktop (SingleInstanceService), information about which files to use, which should not necessarily be trusted, can be passed through an applet using the PersistenceService ("muffins") or, apparently if the browser is IE, through cookies.
I've found a solution that suits my needs. A custom servlet is used to modify parameters in the URL string.
http://forums.sun.com/thread.jspa?threadID=714893