Embed a browser in a asp.net web-based tool - java

[Note: I have modified my original post to provide some clarifications - m.e.]
Does anyone know of a way to embed a web browser within a web page, e.g. through a Java applet or similar mechanism? I have reviewed the discussion on various solutions for embedding a browser in a Java application. However, this will not work for our web-based tool, which is built on an asp.net framework. Using a Java applet is our current idea, but if you have other suggestions to address this issue, please post those as well!
This is to be used in a web-based tool that guides middle school, high school, and college students to read websites critically. The tool provides a set of guiding questions and other information along with a data-entry box surrounding the actual 3rd party web-page being viewed. The purpose of our tool is to allow teachers to choose websites for students to view and analyze - or allow students to choose the sites themselves. We (/the tool) do not control what sites or types of media are chosen.
We are currently loading the web-page in an IFrame, but that technique is limited in several ways. It does not provide full control for browser-like features we would like to provide, and is very sensitive to changes in both third party web-sites and to browser versions used by students. The most difficult issue we have pertains to anti-hijacking mechanisms used on the third-party sites. For good reasons, they use mechanisms that make them impossible to load into an iFrame -- that is, when you try to load the page into the iFrame, it will take over the entire browser window. Not only will the page not load WITHIN our frame, it will actually make our application "disappear", thereby making it impossible for students to use these sites within our tool, and potentially also causing students to lose their work.
The tool, which has take several years to develop, is currently web-based for a variety of reasons based on the needs of our users. I would appreciate any advice or insights the community may have!
Thanks.

If you have web application (ASP.NET page as you described), use web-based solutions, i.e. IFrame, etc.
Web browser controls anyway is a desktop solution.

Related

Options to re-using an Applet's existing code?

After five and a half years full-time work on a product ranking engine project, which revolves around a 64,839 line applet, the browser companies have seen fit to dump applets.
At this point I am in no position to convert the applet to another language (unless I get a huge injection of funds to hire a team of programmers). My partner is not going to support me for another two years.
I know the questions are rather vague and I should be keeping up with the latest tech, however I've had chronic earaches for 14 years that affect memory and concentration, so programming is difficult enough without trying to keep up with the latest developments in software as well. The reason I am asking for advice is that I don't want to make another monumental screw up.
Question 1: My understanding is that Java Web Start launches the application, but it then cannot communicate back to the JSF web page any more (JSF2.0). Is there any way of getting around this?
Question 2: Can anyone suggest any other options other than re-coding the whole thing?
Question 3: Is it likely that applets will be altered to use the latest plugin format or are they gone for good? Does anyone have any inside information on this?
Overview of the applet's requirements:
The applet allows a user to customise some or all of the product ranking criteria, which has been preset by a panel of knowledgeable experts, to their own particular needs. The criteria is stored and edited via graphs (custom painted jPanels).
The ranking criteria can be altered entirely using the mouse (to change the graph shapes), though some values can be entered using the keyboard if the user wishes. Once customised, the applet is then used to submit the changes to the ranking engine server.
It is also used to allow third party experts to alter the ranking criteria to create their own product usage category ranking criteria. The third party expert can then place links on their own web site that will allow users to rank products using the third party expert's own ranking criteria. This allows anyone to create their own ranking criteria for use by others.
The applet uses a plugin bean that is also used in a standalone Java editor application, which is used to create a product usage ranking criteria file from scratch (the editor is 77,710 lines of code, though 61,257 lines of that is the plugin which is also used in the applet). This means most likely having to convert the editor as well, as the two are inextricably linked. The plugin basically is the applet and also the editor.
The plugin can capture, edit and store ranking criteria for virtually anything the human brain can rank. Thanks to the graphs, it can use any attribute that the brain uses, and for which we have no formal system of measurement; hence why the applet is so damn big.
Your question is probably too broad for Stack Overflow, but I'll give a brief response.
Java Web Start
Java Web Start is probably the best route for you. This technology is basically a convenient way for a user to obtain, install, and run a Java desktop app. The web browser is only used to initially download a small XML file describing your app and where to get the app. The Java Network Launching Protocol (JNLP) defines these pieces of information stored in that XML file. Your app will be downloaded from a server, and saved to the local machine. A Java Runtime Environment (JRE) can be downloaded and installed if need be as part of the process.
By default the app runs within a security sandbox similar to Java Applets. But you can sign your app and define security protocols to break out of some of those restrictions including making network connections.
The bulk of your programming would remain intact. The app is still pure Java, running in a JVM. You would need to do a bit of reprogramming to be a desktop app rather than packaged as an Applet. And you would have to learn about easing those sandbox restrictions. And your app will have a menu bar of its own as a full-fledged app, so you may want to take advantage of that. But the guts of your app would remain the same.
Over the years, Sun & Oracle have put efforts into improving Java Web Start. Unfortunately it came too late after Java-on-the-desktop had lost too much mind-share. And Swing never got the overhaul it so desperately needed. So Java Web Start never went big-time. But Java Web Start does work as advertised, so give it a try.
While there were some security issues years ago, I believe they have been resolved long ago. The many infamous security problems with Java were largely involving the web browser plugins bridging between browsers and the Java JRE; those problems do not affect Java Web Start (though you should do your own research to confirm).
For the general public, Java Web Start may be too much to ask of new, anonymous, and less-motivated users. For a commercial product with a user-base of eager customers, it may the perfect solution for you. I suggest you do some more study, read the Wikipedia page, study the Oracle technology page, look at the Tutorial, read this overview by John Zukowski that includes an example of network (making socket connection to time.nist.gov), and so on.
Vaadin
The Vaadin framework is an open-source free-of-cost professional user-interface development framework that uses pure Java to run your app on a server in a Java Servlet web container while automatically generating a user-interface using standard web technologies (HTTP, HTML, CSS, JavaScript, GWT, WebSocket, etc.) for presentation within a regular web browser (Firefox, Chrome, Safari, IE, Edge, etc.). As a graybeard, I think of Vaadin as an X Window System for the new millennium: The user interacts with screen widgets on their local computer but the business logic of the app is executing on the server, and the server is updating the remote UI as a result of that business logic executing.
Vaadin is not yet-another-web-templating system. Instead, your app is written in pure Java. No need for you to learn the alphabet-soup of web technologies listed above. Vaadin takes care of that for you, auto-magically. You say in Java “I want a label, then a field, and a button” and Vaadin makes those appear in the web browser.
Using Vaadin would allow you to retain your Java code for the business logic part. But you would need to re-write the user-interface parts to use Vaadin widgets instead of Swing widgets. This would not be so terribly difficult as Vaadin was inspired by the general style of Swing, defining layouts governed by layout managers in which you place your various widgets (fields, labels, buttons, etc.).
Vaadin can make very professional business-oriented apps that feel almost like desktop business apps. Tip: I prefer the Reindeer theme for business apps over the newer Valo theme.
But you mentioned some kind of free-form drawing canvas in your Swing applet. That may be a sticking point. I do not know of such a widget for use within a Vaadin app. I am not saying there is no such thing, I just do not know of any. There are slider widgets that may useful, but I don't clearly understand your needs in that regard.

prerequisites for developing a web browser in java [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to get started building a web browser?
I have a basic understanding of the Java language and also some knowledge about applets.
I have to develop a basic Web Browser for my college project which can display simple websites along with Javascript components.
Could anyone tell me what are the prerequisites i.e, what topics should I read before doing this and how to do it?
Really appreciate the help
Writing a web browser is a major undertaking, depending on the level of functionality you want to include.
Things that need to go into a browser:
An HTTP client that can retrieve the page content from a server. Java includes something very basic inside java.net, but if you can, use the Apache Commons HTTPClient instead. Many browsers also have support for other protocols, such as ftp:// or local files (file://).
An HTML parser, which can read the returned HTML (or XHTML) into an in-memory structure. The hard part here is that not only has HTML evolved; there is also a lot of HTML out there that does not conform to any of the multiple HTML standards. People just tend to write something, see if it can be rendered on a specific browser (say, IE), and move on -- and certain browsers can render almost anything. You can use existing parser such as JSoup for this, which also has limited support for fixing mistakes.
A rendering engine. This would be, for me, the most complex step. You would need really in-depth reading to get any sort of CSS support working (major browsers had a hard time getting it right too), and even non-css rendering such as nested tables or complex forms would imply hard work (to calculate where each page component goes on the rendered page). There are no add-on rendering libraries that I know of, but there is minimal (HTML 3.2?) HTML rendering support inside the JEditorPane - you may be able to use that (forget about advanced CSS, thouth).
Scripting support. This would interpret JavaScript, and make your pages interactive. You can use Rhino for that (maintained by the folks at Mozilla, and very powerful).
(Plus internal caching to avoid making repeated requests; support for saving pages to files; support for 3rd party plugins/extensions such as Flash; security considerations to avoid cross-site scripting attacks on your users ... there are many more components or concerns that I have not bothered to include above).
Since you have only basic understanding of Java, and any of the above components are fairly complex projects in their own right, I would suggest choosing another project or delimiting a very small subset of what a commercial web browser does to try to implement that instead.

When to use GWT and when to not

I am wondering if there are specific cases where GWT is not suitable? For example would it be approriate to re-develop Stack Overflow using GWT?
I am developing an app which has a Java Restlet API and I was planning on using GWT (previously I would just have used bog-standard HTML/CSS with back-end PHP code calling an API). I am wondering if there are reasons why I shouldnt choose to do this?
My answer is not full but I believe the following bullets may be useful.
GWT should not be used for applications that mostly present textual information and some pictures, i.e. not very interactive. For these applications GWT does not bring you a lot of benefits.
GWT should not be used by teams that have strong web skill and relatively weak java skills.
Do not use GWT if you are required to support browsers that GWT does not support officially. For example MSIE 6.
have a look at this topic GWT for big projects?
GWT is best choice to manipulate complex actions in a single page. like Google wave, Google mail ... you can easily update (ajax) any part of the page.
Because of the GWT is java-to-javascript compiler, user should wait the loading of .js files and it causes many and many problems if your web app is big. The bigger your project, the bigger javascript files, the more user should wait the loading of .js files
IMHO If you have a static looking website like a blog, news portals, etc which each page has its own identity and represents an entity and is requested separately don't use GWT alone (you can still mix it with server-side generated pages like FB).
For most of other web apps especially if users sign in to use your app or your app is interactive and there is no technical problem use GWT (like Gmail design).
I would propose to avoid GWT at any cost. I have experience developing huge project with GWT and it is nightmare, because of long development circle. If you have application in angularjs/react/jquery, you update source code, click F5 and reload it. You can quickly debug clicking F12.
If you use GWT on huge project, you have to wait ~1 min for app to compile. And then there is no good way to debug it. Google provided special browser plugins, but they worked unstable and didn't support last versions of browsers, so I had to downgrade FF. Also huge GWT app debuggin takes tons of java memory, so you have to provide more memory to tomcat. And finally in practice you can't avoid learning js, you will have to learn it if you do modern web development.
UPDATE 15.05.2017: My answer was downvoted by GWT fans, but I'd like to note, that my info is up to date: 1-page hello world app rebuild cyrcle takes about 30seconds with last IDEA and 10Gb mem SSD notebook. I also asked friends having GWT in production for serious project: they claim 2min is average redeploy time.

richfaces alternative for website application development

Can you let me know on the pros and cons of using richfaces and are there any alternatives for it. Its for a proposal submission for a web application. Its for managing documents and it will be intranet. There will be lots of users and main concern is security and ease of use.
Don't do it like that.
I suggest you to ask the same question to your team, after all they are the one, who will be developing it.
You must understand and find out what exactly is JSP, JSF, RichFaces, IceFaces, Facelets, AJAX, etc. are. You must know what all these technologies are meant for, and how and where they can be applied to solve which problem.
You should make a toy application using few viable alternatives, i.e. IceFaces, RichFaces, etc.. Then evaluate considering ease of use, support, strength, etc.
It all depends on what you are creating, what your target audience is, which type of devices are used for accessing your application etc
If you are creating something that has to be really lightweight, for example, something that must be browsable on mobile devices, then you should consider how much of the code is executed in the browser, keep that end light and do the heavy work on the server side.
If you are creating something that has to be access with text based browsers, then you should keep your site as simple as possible and make sure you have full control of the DOM structure.
If you are creating something that has to be indexed by search engines (an application like an eCommerce site), then you have to remember that applications made with AJAX-based frameworks will not be indexed by search engines, as search engines look at the static content of the page (by which I mean that the content hasn't been modified by javascript). If you really want to use a RIA framework to create you frontend, there are workarounds to enable search engine indexing, but that's a whole another topic.
On the other hand, if you are making a web application, something like an accounting system or the management part of an eCommerce site, then you can and should consider full blown RIA solutions, because these kind of application do not need to be indexed by search engines and they are often (if not always) accessed through a modern browser on a PC or Mac. Popular RIA frameworks include Vaadin, GWT, Wicket, IceFaces etc.
http://www.icefaces.org/JForum/posts/list/8347.page and http://forums.sun.com/thread.jspa?threadID=5202018
The company that I work for is using AJAX, PHP & MySQL for Web Applications such as Social Networking, Community Sites, Online Booking Applications, etc. on a Standard Comentum Framework (MVC).
For Ecommerce Applications, we use Zend Framework. I think Zend Framework does a good job preventing programmers from sloppy coding:
http://www.comentum.com/web-application-development.html

Please discuss what are and why use portlets

Why would I want to use java portlets above tomcat and gwt?
Would portlets make it less- or un- necessary for me to use jsp and jsf?
Has Jboss been part of the portlet evolution culture? Does Jboss satisfy the portlet jsrs?
What portlet implementation/brand would run on gae java and gae python?
Are portlet specs due to peer pressure from php cms culture?
What are the equivalent of portlet and portlet jsr in .net?
Portlets were a well-meaning but mis-guided attempt at a reusable widget API for web applications. Think of the personalised google home page, with the portlets like weather, news, mail, etc.
Unfortunately, they made a bit of a mess of it. The Portlet API is a bit of a pig, a real barrel of not-fun, and there are very few implementations of it. The only one I've ever used is JBoss Portal, but it's a bit of a brute, and rather buggy. Liferay may also be a portlet server, but the home page is heavy on fluff and light on information, so I can't tell.
Spring provides an MVC framework for the portlet API which tries to reduce the pain, but frankly I wish they hadn't bothered, it just clutters up the documentation.
Essentially, the whole shebang looks like a solution in search of a problem.
If you happen to have a framework that you need to use, and it supports portlets, you may find then that portlets are going to be useful, since the application is built with the idea, but, as others have mentioned, if you are starting on a project, there are many other technologies that will do what you want with less effort, in a more stable environment.
For example, when I worked at the University of South Florida, the learning management system was (and is) Blackboard, and they now support portlets: http://www.ja-sig.org/wiki/display/JSG/Blackboard+Portlet. So, if the application provides an API, and expects people to use portlets, then it may make sense to look at them.
UPDATE:
After looking at the question there were a couple of things I missed.
Portlets were an attempt, it seems, to try to do as Google did on their homepage, where you could have multiple unrelated blocks of information on the webpage, so you could track your stack portfolio and your favorite hockey team, for example. I don't think it was influenced by PHP CMS as it was just an idea that was ready to come about, and if you need the server code to help pull the information, and to tie it into an application, this was one approach.
The closest thing in ASP.NET that I can think of to portlets are controls. I could have a stock portfolio control and when I include it on my page, you can set the options and it will show you your stocks and hockey team scores.
Not everyone uses JSF, for example, so controls would need to be written by hand as JSPs and servlets, with javascript.
Why would I want to use java portlets above tomcat and gwt?
These technologies are not directly comparable. Coming from regular web page development, Portlets seem like a very restrictive technology. But then the value of Portal servers is largely the control they give to administrators and users - the fact that this makes your life more difficult is irrelevant.
Would portlets make it less- or un- necessary for me to use jsp and jsf?
You can write directly to the output, just like you would in a Servlet. You probably still want a view technology (that will have to support portlets).

Categories