Home arrow static arrow Java Programming [Archive] - Can Java Interact with Web Pages??
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Can Java Interact with Web Pages??
This topic has 8 replies on 1 page.

Posts:25
Registered: 8/9/04
Can Java Interact with Web Pages??  
Aug 9, 2004 1:26 PM



 
I wonder if it possible to develop an application or applet that can automate the process of signing up for courses at Notre Dame.

Currently, we have to use a pretty plane text-based web system. I wonder if it's feasible to use Java to provide a more user-friendly front-end to this system. The program would need to read HTML, view different web pages, and write to web forms. Any tips on where to go from here?

I realize that some other language might work too, but I'd like to advance my Java skills ;-)

Thanks!!!

- Brian
 

Posts:14,142
Registered: 99-04-02
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 1:39 PM (reply 1 of 8)



 
Sure.... it could.

You would probably want to look at the java.net.URL and java.net.URLConnection classes, which make it easier to talk to HTTP servers. As long as you know what the form fields are, you could write a front end which submits the form data like a browser does.

However, if you aren't adding any benefit other then a better look to it, then maybe it'd be better to just update the web pages themselves to look nicer.
 

Posts:25
Registered: 8/9/04
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 1:45 PM (reply 2 of 8)



 
Thanks for the tip. The reason I can't change the web page itself is because I have no say in its design.
 

Posts:14,142
Registered: 99-04-02
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 2:00 PM (reply 3 of 8)



 
Well, are you going to be able to put this applet on the server? If you use an applet, it'll have to be signed if you are serving it from a different then the web server that has the regular forms. Or use a stand-alone app.
 

Posts:25
Registered: 8/9/04
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 2:03 PM (reply 4 of 8)



 
That's a good point. It looks like a stand-alone app is best, given that I have absolutely no control over the server that I am trying to interact with.
 

Posts:11,200
Registered: 7/22/99
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 2:32 PM (reply 5 of 8)



 
From what you've posted so far it sounds like you want to make a specialized web browser. Is this what you had in mind? The Java API includes two classes that can be used to construct such a beast relatively easily: JEditorPane and JTextPane. The Swing tutorial has a page on how they can be used:
http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
However, their capabilities are rather limited (only support HTML 3.2). They will let you change text styles and the way pages look, but will hardly be more "user friendly" than the original site because it'll be only the old thing with a new look.

There's also a HTML parser that can be used independently of the gui components, in principle you can use it to extract information from the site and show it in a completely new user interface that has nothing to do with the original site but I haven't used it much and i'm too tired to look up and example on the 'net (been a long day, i'm off to bed)
 

Posts:25
Registered: 8/9/04
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 2:40 PM (reply 6 of 8)



 
That's exactly what I need! An html parser... but I'd also have to input text into forms, too.
 

Posts:11,200
Registered: 7/22/99
Re: Can Java Interact with Web Pages??  
Aug 9, 2004 10:48 PM (reply 7 of 8)



 
THe package javax.swing.text.html has a HTML parser that produces an instance of [url http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/text/html/HTMLDocument.html]HTMLDocument[/url]. There are some examples of reading a page and extracting information from it here: http://javaalmanac.com/egs/javax.swing.text.html/pkg.html

When working with forms you'll be interested in the tags FORM, INPUT, TEXTAREA, and SELECT.
 

Posts:196
Registered: 6/24/97
Re: Can Java Interact with Web Pages??  
Aug 10, 2004 3:59 AM (reply 8 of 8)



 
There is quite a bit that can be achieved - both on the client and server side using java, only limited by your drive, motivation and imagination.

On the client side, you can use Applets. Applets can communicate with their surrounding web pages and can even launch new browser windows and web pages (provided they are signed). However, their behaviour/reliabality is difficult to control as they could be executing inside a host of different browsers and jvms.

On the server side you have a range of technologies - simple java programs to full blown J2EE servers that can do the type of automation that you are looking for.

If you are setting out to learn the language, do have a look at JSP, HTML and CSS - with a bit of creativity you can do wonders with it
 
This topic has 8 replies on 1 page.