Identifying Java desktop client dependencies for web apps - java

We have a set of web apps and want to identify if they have a Java client-side dependency i.e. if they invoke the client installed JRE.
Is there an easy way to do this? or do we have to manually scan the code for or anything else that may have a Java client dependency?
Thanks.

No, there is no easy way to do this.
It would be easy if all your web-apps would use a <applet> html tag or a <object> html tag, then you could simply match every html source. This you can do anyway to find some of the web-apps that use java, at least on the start page of the app.
But since it is also possible to load java applets using javascript and an automatism cannot navigate through an app like a user, there is no easy way to do this.
If you have control over the clients (e.g. company internal), you might turn off java on a few clients and let the users do the checking (e.g. they will call if something does not work). Maybe you even have key users for application tests.

Related

URL without hash (#) in GWT

In GWT i need to use # in URL, in order to navigate from one page to another for eg. www.abc.com/#questions/10245857 but due to which i am facing problem in sharing the url.
Google scrappers are reading the url only before # i.e. www.abc.com.
Now i want to remove # from my url and want to keep it straight as www.abc.com/question/10245857.
I am unable to do so. Please help me with some links or code.
Thank you
If you want URLs that don't use the hash, then you have to use HTML5 pushState (browser compatibility).
You cannot do that if you use the History class directly; you'd have to create your own History class that use pushState and use that class in your code instead of the GWT built-in one.
If you use Places, then it's much easier as all you have to do is implement an Historian rather than use the DefaultHistorian; e.g. https://gist.github.com/tbroyer/1883821
If you need to support browsers that don't have pushState, then things get much more complex.
There are alternatives though:
you can use #! and implement the necessary server-side hooks: https://developers.google.com/webmasters/ajax-crawling/ (there are projects that implement this by running your GWT app within an HTMLUnit pseudo-browser on the server; IIRC, GWT-Platform has such a feature)
you can provide permalinks to your "places", like Google Maps or Google Groups do; see https://stackoverflow.com/a/24717441/116472
The # represents places inside the application so to change the URL try Creating different GWT entry point modules could solve this issue – there would be only one web application this time, but each module would be accessible via a different URL. Look into this article http://www.summa-tech.com/blog/2011/02/22/structuring-gwt-modules-for-large-applications/

How to generate different HTML based on the device that access the page?

I am using Java EE 6 with all the reference implementations and I wonder how you can generate different responses based on the device accessing the page? At the moment when I develop a JSF page I target browsers running on PC. However I want to generate another HTML structure (that is, using another JSF page) when the user browses the page with a smart phone.
Now you wonder, "Why doesn't you use CSS media queries?". Yes, I could but that will only give limited control over the layout. Could someone give me some hints to where and what to start reading about to do this?
I don't want to use Spring, I know they have something like this.
I don't want to use Spring, I know they have something like this.
Just reinvent it then (cough).
Let's look how they did it. According to the Spring Mobile documentation, cited below,
LiteDeviceResolver
The default DeviceResolver implementation is based on the "lite" detection algorithm implemented as part of the Wordpress Mobile Pack. This resolver only detects the presence of a mobile device and does not detect specific capabilities. No special configuration is required to enable this resolver, simply configure a default DeviceResolverHandlerInterceptor and it will be enabled for you.
it seems that they have ported this piece of PHP code to this piece of Java code. You could just do the same (be aware of license rules!). The most sensible place for this would be a servlet filter which would then send a redirect depending on the outcome of the detection.
I think you will need to look to the HTTP_USER_AGENT.
No experience with Java, but look to System.getEnv("HTTP_USER_AGENT").
It should return a string name for the user agent. You should find in the web lists of common user agents, so you can easily classify them as mobile or not mobile.
Inspect HTTP header
user-agent
you can retrieve this using Servlet API: http://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getHeader%28java.lang.String%29

Retrieve a list of browsers/agents installed in client system

I would like to write a web application (in django) which scans the client/remote computers (assumption is windows) and retrieve the list of software's(mainly browsers) installed. Looking for suggestions to implement it.
Is this possible without asking the user to download any scritps/exe's?
If so, is it possible via java script?
I am planning to use python/django to write the entire app. Any input would be much appreciated.
EDIT : Comments on feasibility in java also much appreciated
Short answer: No, it is not possible
Long answer: This is something that any sane (operating) system designer / administrator would try to prevent - scanning of local system by a web page. However, you could use a plug-in component, such as a java applet, to do so - but in practice you probably would need to handle each client platform (OS) separately, since each of them has a different way of storing the information of installed software
You want to access the data from the client side so from the conceptual/logically its not good to access the client system. You have to use some medium which run on client side on behalf of server.
JavaScript and JavaApplet is good in this. You can get the data by JavaScript or Applet and in backend you can send data to the server.
You cannot do this unless you have some signed control installed on the client computer; or have them download a program which runs (separate from a browser) and sends the information to your server, where your django app can access it.
This is not possible using javascript (as it runs in a sandbox).
"Scanning" a client from a server may be possible if you break their security or get them to break it for you through some extension (see windows udate, for example). Either way, it's evil.

Provide an interface between the web browser and a Java application

Which language/tool do I use to provide an interface between the web browser and a Java application?
My task is create a web page and provide a feature which will enable results to be uploaded as XML files to dynamically update the page.
I have been instructed to use languages such as Java, Javascript(JQuery), Ruby, Grails, PHP etc.
So I have so far written some java classes that will process the XML files but I am running this application from the command line. I DO also understand how to display the XML on the web browser using XSLT.
My problem is, that I have only ever written desktop applications... I don't know what tools to use to provide an interface between my java back-end and the web front-end or how to (for lack of another method) invoke the JVM from the browser.
How do I send uploaded XML files to my java classes and get the XML results back? Can anyone shed some light into which tools I should use and the network packages (if needed) I need to import in Java? (note: this only needs to be run locally)
Feel free to make edits to tags/title and question if necessary.
I have been working in java and i feel that servlet-jsp are the best option
to full fill your requirement.

When JEditorPane will not do. JRex, JRex wherefore are thou JRex?

IDEA: Implement a recent web browser into a java application (for saved offline, non server content).
The question is this: can I have a java application implement a webbrowser with jquery / html / css support within a java program?
So I am asking anyone who has played with JRex for advice: I want to know how complicated will it be to integrate an open source webbrowser into java. I am not all that keen on the idea of compiling Mozilla from source build. Is there a ready made compiled version?
Is there a simplified method to have latest compiled version (most current in terms of support for HTML css & javascript), and integrate that into an application?
Also: I appreciate the amount of work required to support for HTML4 nevermind 5, and CSS2 compliance. How close is JRex to that?
Application: My intention with the webbrowser is to render a webpage from offline content. It will not need to be online content, and will simply be for file based displays = e.g. file:///C:...
Does the webbrowser have to be wrapped into a server to function, e.g. to pass files to the browser to render is how complicated? I am not keen to have to implement Jetty or another server type application just for this.
If JRex is not the solution... what then? Is it possible to start a browser implementation within Java and can Java interact with the information and traverse the Dom?
Or alternatively is there .hta equivalent in recent browsers like firefox?
If you need to have the embedded browser interact with your application code, you could try the SWT Browser control, it's actually maintained as opposed to JRex. Browser uses either WebKit or Gecko or embedded IE as appropriate, or lets you choose which one you want, so it should run jQuery and familiar Javascript. And since SWT is a JNI library to begin with they probably already have guidance on how to deploy an app that uses JNI.
You can feed HTML into the control from a string (example) or a java Url - which can point to local files or resource files in your JAR, which I assume will let you split your app into different files.
To call Java code, you need to expose it as Javascript functions. example
To manipulate the HTML from Java code, you need to call Javascript functions from Java. example
To make the previous two tasks easier, you might want to look into a JSON library to simplify passing around complex data.
Does it have to be implemented within a Java program? Could you let the user use the default browser on their machine (ie does it matter what browser)?
If not would use the Java Desktop API.
if (desktop.isSupported(Desktop.Action.BROWSE)) {
txtBrowserURI.setEnabled(true);
btnLaunchBrowser.setEnabled(true);
}
If you are using Java 1.5 try http://javadesktop.org/articles/jdic/

Categories

Resources