prerequisites for developing a web browser in java [duplicate] - java

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.

Related

GWT + symfony2, am I crazy?

Does anyone has experience on integrating GWT and Symfony2?
Currently I'm using Symfony2 with the frontend being JQuery + HTML.
Writing Javascript drives me crazy although JQuery has already been used.
I'd like to know if there are any successful cases? GWT can generates javascript for me.
I only need to write type-safe and OO Java.
But, there is another concern, with GWT normal practice, the HTML elements are all created dynamically. So when a page is being crawled by the search engine, there are no elements for it to crawl. Is it a serious problem affecting the SEO rank?
GWT is a powerful tool you can write your code in java and GWT will generate Cross browser supported JavaScript.
Dynamic pages are created on the fly. These pages function well for users who visit the site, but they don’t work well for search engine crawlers.
Why? Because dynamically generated pages don’t actually exist until a user selects the variable that generate them. A search engine spider can’t select variables, so the pages don’t get generated and can’t be indexed. There are different strategies available for reference check Dynamic sites SEO tips

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

[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.

Developing traditional style webapps with GWT

In many JVM web frameworks survies and Indeed.com trends graphs, GWT looks to be the most (or among the top) popular JVM framework.
But AFAIK, GWT excels when the application is one page app -to some degree of course- (like GMail, Google Reader ..)
Does this mean that new developed Java webapps are one page apps mainly (not traditional request-new page response)?
Is it possible to develop SpringMVC or Struts2 style webapps with GWT? or it is not recommended?
Absolutely, it is definitely possible to build struts apps with GWT; at some level all the GWT is, is a convenient way of writing javascript (in my perl days, we called it 'syntactic sugar').
You can still use GWT-RPC, JSON, or HTML forms to communicate with the server.
You can attach to any arbitrary HTML element using RootPanel.get("id"); to add javascript widgets.
Almost every javascripty component on my employer's website is written in GWT: http://www.cohomefinder.com/ . The backend is an old fork of struts.
And here's a nice, though a bit dated, article about building 'normal' websites in GWT: http://www.canoo.com/blog/2007/03/13/building-a-regular-website-with-the-google-web-toolkit/
I'm not sure, however, that this use of GWT is where it really shines. One downside is a lot of javascript parsing on every page load. Code splitting can help with that, some.

Making Web Forms: Java vs HTML

I am new in programming and this question may really be stupid but I still want to ask because I don't know what practices are possible and what are not. You see, right now I am studying basic J2EE. Our assignment is to make a web-based application using JSP and servlets. One of my problems is doing the forms.
I know that HTML is the best practice in making the forms in JSP because almost all people are using it(based on the examples on the books/internet). But Java also have its own forms which is the Swing, AWT and it all worked by using the events. If i don't want to use HTML, can I use Java's Swing/AWT or is it for the desktop applications only? Aside from what I've mentioned, what else can I use?
What you are talking about is called Rich Internet Applications RIA. These are web applications that make your web pages look like desktop applications. You can achieve this with Grails and Flex, GWT and JavaFX. There is a number of very interesting and great environments you can use like Vaadin, Open Laszlo, based on GWT. GWT and the frameworks based on it generate JavaScript and produce separate output for every browser environment.
These are the tools for the future. I do not really understand why these technologies are not mainstream yet.
Here is a list of the various RIAs frameworks available. Expect to welcome newcomers in SourceForge in the near future.
But Java also have its own forms which
is the JSwing, Swing, AWT and it all
worked by using the events.
Yes java has many Components in Swing and AWT.
And both Swing and AWT Components support Event Handling.
But I never have heard of JSwing.
If I don't want to use HTML, can I use
Java's JSwing/Swing/AWT or is it for
the desktop applications only?
Swing and AWT are for the desktop application only.
But as Orbit said
In Appletz? – Orbit
You can definetly use Swing components on an applet and then embed the applet on your JSP page.
I know that HTML is the best practice
in making the forms in JSP
Using HTML will be a lot easier than using Applet to make a form
As Andrew said
Applets are a PITA to develop and
deploy, and most users prefer pure
HTML (or dynamic HTML, using
JavaScript) to applets.
You can try out Wicket - seems like transfer your desktop expirence to web
Perhaps you need to think about what is running where, and how those programs communicate. When you develop a web application, you are co-ordinating a conversation between (at least) two separate machines.
On one side, you are running a web server, that serves up static content (simple files that are just sent out with no changes) and dynamic content (essentially files that are constructed only when needed, and that will change according to their situation - for instance a welcome page that displays the user's name). Plain HTML is static content, JSP and servlets provide dynamic content.
On the other side, you are running a browser. The browser can display static content, run javascript programs built into those pages, and embed specific types of applications. Examples of embedded applications are Flash and Applets.
So you can be clear, JSP and Servlets are NOT running on the client machine, they just deliver different content for the browser to display. A J2EE program is not delivered to the client, it just sits on the server carrying out one side of the conversation with the browser carrying out the other side.
A web form is just a lump of HTML that tells the browser to display text fields, buttons and other controls. The browser knows all about these things, and you don't need to write a program to tell it what to do to display a form and send the content back to the server. A simple form doesn't need to be dynamic - you're asking the same questions every time - so you can write it in pure html.
When the user submits the form, the data is transmitted to the server and you will need to write a program to receive that data and do something with it. That is the role of the servlet, which can receive data and respond - with another web page, probably using JSP to display dynamic content (ie. the answer to the form submission).
If that all sounds complicated, it certainly can be. There are various frameworks (Wicket, Struts and so on) that try to make it easier to develop web applications by hiding some of the details of the conversation, and carrying out common tasks automatically. However, the underlying mechanism is still the same - content from the server is displayed on the browser, which can send back messages such as form contents, or requests for different pages. Understanding the basic mechanism allows you to make informed choices about how you can do more powerful things.
Embedded applications allow you to run more complex software on the client - so you can display animations or custom controls. However, the software is ONLY running on the client, and still needs to communicate data back to the server. The server still needs to be running it's own software to receive that data and do something with it. As such, embedded applications don't make your job any easier, but do allow you more control over how things work on the client. However, a modern web browser gives you a lot of control over how forms are displayed and handled, so you need a good reason to ditch that and use something like Flash or an applet.
For websites, always use HTML (and Javascript, for things like input corrections, alerts and such). The less you use Java and Flash, the better.
Keep in mind that websites must be fast and efficient, users don't want to wait minutes until the Java applet loads.
I would recommend you to do in HTML. Because HTML can do wonnders and you can split your web apps sematically using HTML. And i recommend you to use Wicket(its an framework), where all are been splited. That is, web designing can be done separately using HTML, presentation can be done via CSS and the event handling all can be done via JAVA. And wicket takes care of all these connections too. So have a look on Wicket. And hope it helps you.!

Handling CSS and JavaScript when building a Java browser

My task is to create a simple web browser in Java.
So far it can only read HTML pages.
I'm using standard JEditorPane component to display webpages.
Now I was wondering is there any way you could explain me how can I manage to display at least some simple pages that contain CSS/Javascript.
If you could point me to some useful links or appropriate examples I would be very happy.
Well, my advice would be to look at open source rendering engines such as Gecko - https://developer.mozilla.org/en/Gecko_FAQ
You can embed Gecko with Java using the JREX library - http://jrex.mozdev.org/
Starting from scratch with a problem like this is a very big task, and as your username is AmateurProgrammer, I wouldn't recommend it.
There alrady is some prior art for the Java browser segment.
concerning javascript, you will have to use a javascript interpreter in Java. A renowned one is Rhino (by Mozilla). Its integration may reveals to be an interesting challenge.
concerning CSS, it seems the question has already been asked ...

Categories