Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > JSP, Servlets, Beans, and MVC -A cry for HELP

JSP, Servlets, Beans, and MVC -A cry for HELP
Thread Tools
depolitic
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 18, 2004, 07:37 AM
 
Hi - THIS IS MY CRY FOR HELP AND A LITTLE SANITY -

I have built a simple model 1 web-site using JSTL, no scriptlets nothing but JSTL - I have used a basic MVC design, with specific pages for each aspect of the MVC.

Now it works and I can add remove and edit my MySQL database with ease. However I still have allot of logic and controll code in my .jsp pages.

Now every one tells me that I need to move to a model 2 MVC - because it is the done thing and that is how REAL programmers do it - Even when I am just a graphic web front end hacker - and I can see the logic behind this view, with the whole separation of function philosophy.

However - maybe I am stupid - which I am not - but J2EE is a F-up mess - I have O'Reily's book on Java Server Pages and their Servlet Book. Now the JSTL stuff I am cool with however even when Bergesten tries to build even the simplistic of three page web application using a Model 2 architecture he ends up employing JSP, and Servlets, and Listeners, and Filters, and Beans, and XML, and the Struts controllers serlvets for a simple 3 page site. I makes me wonder if this supposed fantastic Java J2EE system is really that good.

He has these illustrations to show how it all relates however all it show how much of a mess it all is. Lines going every going around and around.

Bergesten has two XML files with a dozen entries, 5 serlvets for SQL abstraction 6 more servlets for the Application and a about a Dozen more utility beans and servlets and the struts framework servlets to boot. TO DRIVE A 3 PAGE SITE - People ????????

Now O'Reily's book on Java Server Pages book is supposed to teach you the basic - if this is the basics boys and girls then I think something is wrong with this cup of coffee.

Now does not all this seem rather Bizarre that MVC or is it SUN in its aim to make things easier has created this bloated mess of technology.

An old Chinese saying that I love goes like this - says - "Any solution that needs a genius to figure out is not much of a solution" - Where does this leave Java and the web.

Now essentially I have a small site, login.jsp + viewBlogEntries.jsp, createBlogEntry,jsp, and an editBlogEntry.jsp and a MySQL DB.

Is their a simpler way - to build a modular site with JSP, Servlets and possible Beans?

I am not building an online bank just a private blogging system for personal use. - I thought it would be fun to try. God did I get that one wrong.

Now this is only the tip of the iceberg, I am also aware of a dozen supposed "Leading Edge" "The best of the best" J2EE solutions out their both from SUN, Apple, Jakarta, and a Dozen other companies. Each with their own frameworks, logic, and solutions. - All claiming to be the "Way" to J2EE nirvana, it however all smells fishy. and All having their devoted fans.

All I want is to build a site, nothing more - why is this supposed wonderful solution so complex?

Now, I am going to get those PHP folks who tell me, that they have seen the light, and so should I- firstly I am on this path, I would like to finish it, before my brain tumours explodes - call me stubborn. Secondly I fear that PHP would not be much less complex once you start getting into MVC. Thirdly - I did the whole PHP thing, and Java is much preferred language.

Having said all that - if anyone has a true object orientated language with good developer support and support for Mac OS X with the power of Java - i.e. Ruby, Python, or yes PHP 5 (last time I used PHP it was just at version 3) or other - please I would love to hear from you.

Because I am getting very disillusioned with the whole lets show the world how smart we are by building stupendously complex systems called J2EE that only rocket scientists could ever hope to grasp, thus making us looking so much geeker before all those mere mortal.

HELP ? ? ? ? - There must be an easer way then what Bergsten has set forth.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 18, 2004, 11:54 AM
 
OK - This is not looking good -

Had a look at Ruby and while it looks like a nice language for the web it is driven all by eruby or mod_ruby modules for Apache, I am in OZ their are no hosting companies for such a solution. Plus it looks much like scriptlets to be honest, - Their is some buzz about a MVC framework for ruby called rubyonrails however their site is down? - Lots of rave reviews however can be found.

It seems I am not the only one not happy with the official J2EE complexity, someone suggested that that is why their are so many competing solutions all trying to GET AWAY from SUN J2EE for Java.

I am looking next into Python - their is ZOPE, it looks HUGE -

I still have to look at PHP 5 which seems to have just come out and looks like it going to be a Java clone, total OOP focus, but still looks like lots of logic in view pages. The common opinion I am feeling from the web is that PHP is a great RAD tool for quick fast hack sites but is not so well equipped to deal with maintenance issues over time.
( Last edited by depolitic; Oct 18, 2004 at 12:10 PM. )
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 18, 2004, 07:39 PM
 
Nearly 20 views and not even a single comments, come on - even if you call be a dumb as mother f-ck-er as long as someone has something to say.

I need answers, I have been scouring the web and the best I have found is model 1.5 of a MVC - but even the author says it sucks long term.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 18, 2004, 10:44 PM
 
Well talking to myself - how unusual.

-------

Ruby is looking way more interesting at this time - I just cannot say no to that Japanese cool.

Anyway - yes Rails is back up and from what I have seen it shits - and let me say again SHITS over everything I have seen from the Java Frameworks, no XML files, not descriptors, all Ruby, not a dozen technologies hacked together. I will have a play with it today and get back.

My only concern is hosting - however it says that it tuns in Fast CGI which should work for me, no need for mod_ruby or eRuby.

A CGI now that is a world I thought I would not be seeing ever again, but he.

You look at the movie at Rail.org way interesting.
     
ntt
Fresh-Faced Recruit
Join Date: Jul 2003
Location: Seattle, WA
Status: Offline
Reply With Quote
Oct 19, 2004, 12:04 AM
 
I understand all your issues with J2EE.

That said, have you looked into struts?
Or writing a servlet to handle the request, and using your JSP purely for presentation, passing a javabean from the servlet to the JSP with your data?

There are ways of doing simpler Java websites. Certainly the full-blown J2EE with EJB etc is way too complex for everyday use.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 12:20 AM
 
The use of struts and all this junk is what my original post is about - it is all way to complex.

I am going to play with Rail and from the looks of it its approach is far simpler and far more flexible then any Java MVC I have seen.

I like Java but if needless bloat is the way Java developers like their solutions then I am moving on.
     
ntt
Fresh-Faced Recruit
Join Date: Jul 2003
Location: Seattle, WA
Status: Offline
Reply With Quote
Oct 19, 2004, 12:53 AM
 
I think you may be over-complicating things.

At its simplest, MVC2 could be implemented using a servlet for every type of action, and a corresponding JSP page. For convenience, add in a couple of javabeans for packaging data easily for use by tags.

In the case of your app:

Servlets
IndexServlet
ModBlogServlet
LoginServlet

JSP
index.jsp
login.jsp
modblog.jsp

Javabeans
BlogEntryBean
BlogPageBean

ModBlogServlet can handle both the case of creating and editing a blog entry. Just look for input parameters, set variables and hand off to modblog.jsp for prompting for input... or if an entry is being submitted write it to the database and return to IndexServlet.
IndexServlet can fetch a page's worth of blog entries from the database, stuff them into BlogEntryBeans, stuff them into a BlogPageBean and hand that back to index.jsp for easy display using tags.
LoginServlet can handle authentication on the database, set a session variable, and return to IndexServlet.

I don't think this example is particularly complex, and I believe it conforms to MVC2 on the basis that it separates JSPs and Servlets into form and function, respectively. No need to use a framework or be a genius to understand it.

I think the real benefit to using a framework such as struts is that you get a set of tags, validation model, base classes etc that can save you time when working on a larger project... and they are easier to reconfigure and build in support for multiple languages etc.

Hope that makes sense.
     
beamso
Fresh-Faced Recruit
Join Date: Nov 2001
Location: Melboune, Australia
Status: Offline
Reply With Quote
Oct 19, 2004, 02:21 AM
 
The content of the books that you've looked at are as much proper architecture as what the code actually does. I use Struts... it may be overkill, but the validation is good. The biggest hurdle with Struts is that the free documentation included with it is aimed at the wrong audience (current Struts developers and not people learning). The suggestions by ntt are pretty good. Tomcat does come with it's own version of the 'LoginServlet' if you have a look at the supplied documentation.

MVC2 is simply not embedding Java code in the page (and not modifying the Java objects in the page but rather when the forms submit)... like using c:forEach for iterating through a list of items rather than creating an Iterator inside the page and iterating through.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 02:37 AM
 
that makes sense - I wish that the oreilly book could put it that way. If you told me that yesterday before my little spat, then I would have happily and to my ow detriment have gone down the JSP, Servlet, Bean Path.

However I have worked my way thought the Ruby on Rail movie

http://www.cframe.org/files/rails_setup.mov

and let me say Ohh my mother f-ing good.

I wrote - read this this much code :

scaffold : post

YES - that is it all the code I wrote a total of two words. And what did I get for all my efforts. I complete MVC design - Rail built the database abstractions for me - generated the HTML form for the data entry, a lists page to view a list of entries, an edit the list form to edit entries and a delete button to delete unwanted entries.

Oh I also had to go to the enormous task of adding the variables for the database in a single plain text configuration file.

This is what is in it -

production: << Database Type
adapter: mysql << Database type
database: scuttlebug_production << Database Name
host: localhost << obvious
username: root << obvious
password: password << obvious

I did in 2 minutes what it took me a day in JSTL using only a model 1 design - In 2 minutes I have a complete type 2 MVC design.

Their is no way that Java can match that? I doubt you could find a faster and simpler way.

Now you would say that will only work for small sites but look at this -

http://www.basecamphq.com/

Built by one guy in a month - http://www.loudthinking.com/about.html

Just have a look at the Video and try it out?

Now to be fair to Java is not Java's faults J2EE has become a mammoth its all the comities that design J2EE all putting their 20 pounds of lead in Java boots.

Ruby - may not be static typed, and may not be English or made by white men, but f#&k if this is what it can do driven by a handful of enthusiasts - Java, PHP, or .NET really has no excuse for being as bad as it is.

Sorry to sound like the converted but I have had an epiphany.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 02:49 AM
 
Ohh I forgot to mention - no compiling, no classpaths, dynacim loading, thanks to ruby.

Add a column in an SLQ table - and the whole site reflects that change - all you do is reload the page, and the form for that table appears in order that you placed it in the sql table. Move the location of the SQL table row, and the web form dynamically reloads and move the form to reflect that change.
     
ntt
Fresh-Faced Recruit
Join Date: Jul 2003
Location: Seattle, WA
Status: Offline
Reply With Quote
Oct 19, 2004, 03:07 AM
 
I haven't had a chance to play with ruby before, and the demo video is certainly very interesting. Although I suspect there is a lot more work required for custom apps (I could be wrong).

I've had respected colleagues mention Ruby before and how great it is.

So if you choose to go with Ruby, that's cool. If your ISP/webhosting provider supports it, even better. Not many support JSP/Servlets as it is.

Glad you've found a useful tool, and that you've learnt a bit about java and MVC2 etc on the way. And thanks for drawing my attention to Ruby again.
     
depolitic  (op)
Registered User
Join Date: Feb 2003
Status: Offline
Reply With Quote
Oct 19, 2004, 03:45 AM
 
I will say that I am having one problem with Rail. The documentation - I am so used to Java documentation spanning pages of stuff, complex UML diagrams and endless jargon and acronyms. With Rail you are lucky to get half a page and guess what is more then enough hand holding.

It nice but unsettling.

I will post back tommorow with further progress maybe I will hit that pot hole soon.
     
   
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 03:23 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,