Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-25-2006, 08:17 AM   #1
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Rep: Reputation: 30
Java: Generate html code

Hi all,
does anyone now, if there exists a HTML-API for Java?
For PHP, e.g., there are classes like HTML_QuickForm or HTML_Table that encapsulate HTML objects and generate valid HTML via toHtml() methods. CPAN provides similar classes for perl.
I like those objects very much and don't find anything similar for Java. :-(
Old 11-25-2006, 11:34 AM   #2
Senior Member
Registered: Jan 2005
Location: Canada
Distribution: ubuntu
Posts: 2,539

Rep: Reputation: 60
if you want something like PHP/ASP as in dynamic web content, but you know java, try JSP. i dont know of any commands your referring to, thats all i can help.
Old 11-25-2006, 09:09 PM   #3
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Clemente -

nadroj is 100% correct. The reason PHP classes like HTML_QuickForm or HTML_Table work (or, for that matter Perl::HTML or any of a million other handy, language-specific class libraries) is because PHP can safely assume that it's running within (or at least alongside with) a web server, and it's practical to emit HTML in a programmer-friendly way.

The Java equivalent is JSP. The most common "servlet container" for JSP is Tomcat.
Old 11-25-2006, 11:44 PM   #4
Registered: Jun 2006
Posts: 62

Rep: Reputation: 15
I would recommend the JSP route, but if you want to do everything from your java app, look into the google web toolkit.
Old 11-26-2006, 11:11 AM   #5
Registered: Aug 2003
Distribution: Debian, Ubuntu
Posts: 188

Original Poster
Rep: Reputation: 30
Hello and thanks a lot for your answers!
I - personally - don't like this HTML/PHP code mixing very much. These programmer-friendly classes lead into more pretty code what is the mai reason for me to search some java pendants...
I will play with JSP and hand coded HTML and I will look into this google web toolkit... After this, perhaps, I will write some html.quickform and html.table packages for my own ;-)
Greets and good week to all,
Old 11-26-2006, 01:21 PM   #6
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi again, Clemente -

A couple of notes:

1. I agree (and Sun agrees with you) about the pitfalls of mixing HTML and scripting. Although you *CAN* mix Java and HTML in the same JSP (creating a JSP "servlet", similar to the way PHP and ASP do it), Sun says that you *SHOULD* use "JSTL tags" whenever possible.

So: if you bother learning any JSP, it definitely would behoove you to look at the JSTL tag library at the same time. I think you'll like it.

2. GWT definitely looks interesting.

I'm not extremely familiar with GWT, but it looks like its main purpose is to simplify writing Ajax-based (client-side) UIs that can talk to Google Web Services. GWT is primarily a *client side* technology; whereas PHP and JSP are primarily *server side* technologies. Furthermore, the GWT "compiler" generates JAVASCRIPT, not Java byte code.

It definitely sounds interesting ... but it may, or may NOT be, what you're looking for.

3. Book recommendation on JSP:
"Murach's Java Servlets and JSP", Andrea Steelman, Joel Murach

Honorable mention:
"Head First JSP and Servlets", Kathy Sierra, Bert Bates

'Hope that helps .. PSM

Last edited by paulsm4; 11-26-2006 at 02:52 PM.
Old 11-26-2006, 01:39 PM   #7
Senior Member
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 52
I would use a template engine such as Velocity and maybe a framework depending on what you are doing.

JSP+HTML mix is a pain to read, maintain IMHO


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using java randomiser to generate equal chances linuxmandrake Programming 1 04-10-2006 12:16 PM
RSS XML File to be read and generate HTML page redhatrosh General 10 02-15-2006 02:16 AM
html code and including html files Hockeyfan Programming 2 08-22-2005 05:11 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Perl Script Reading a txt file and generate html to be published! kofi Linux - Software 1 09-22-2003 05:12 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration