Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 04-26-2004, 02:26 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,530
sde is on a distinguished road
classes and servlets .. oh my

i'm trying to determine whether it is 'proper' to create servlets to interact with my jsp page, ... or if classes are just fine.

I'm working on a web interface so customers can access their information online. After several other technologies have either failed or just been too slow, we have decided to use Java.

I'm pretty happy we did, except I'm still trying to figure out the 'proper' way to do things.

Currently I have a couple classes. ( customer, phone, product as400 )

I've read a bit about the MVC concept and here is how I would break the different classes down.

customer and phone are just the data structure, or the ( Model ) and my as400 class is where I process the data. ( Controller ) Then of course the jsp pages are my View.

SOOOOOO.......

what is the proper way to do this? Should I make my as400 class into a servlet?

is it 'proper' the way i have it structured now?

usually the 'proper' way to do things is really open ended, but i seem to be coming across more rules as i read and work more with java.

any insight would be greatly appreciated.

thanks!
__________________
Mike
sde is offline   Reply With Quote
Old 04-27-2004, 05:42 AM   #2 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
There's not a really good answer to that. Currently, I'm developing a J2EE site, and I'm only using JSP's.

The goal of a well-designed J2EE site is to seperate business logic from site layout, and maintain the MVC model. The problem many people have with JSP's are that it's just too convient to slip into doing business logic in them. So a variety of other technologies have been made that enforce boundaries more explicitly, such as Jakarta Struts, JavaServer Faces, and Jakarta Turbine/Velocity.

The way I have designed my site, in ad-hoc fashion, is to have 2 types of JSP's, one where something is displayed, and one which processes form data or performs some type of action. Anything involving business logic is initiated in the latter type, but the guts of it is performed in beans. For instance, I'll call an addUser(uid, pass) in a JSP, but the actual adding of a user to a database will occur in the bean.

A goal to strive for is that you should be able to give a quick training session to a web-coder so they can update the JSP as needed, but won't have to/be able to alter the business logic. If you move all that stuff over to servlets, you've ensured that some HTML monkey with a crash-course in JSP won't be able to screw things up. That's also why, despite the fact I don't use them personally, I think people should use JSP Tags instead of escaped code; it enforces the boundary between html monkey and code monkey.
__________________
GitS
Belisarius is offline   Reply With Quote
Old 04-27-2004, 06:08 AM   #3 (permalink)
Belisarius
Java fanboy
 
Belisarius's Avatar
 
Join Date: Aug 2003
Posts: 1,175
Belisarius is on a distinguished road
Came across this interesting article that you might find enlightening:

http://jakarta.apache.org/velocity/ymtd/ymtd.html
__________________
GitS
Belisarius is offline   Reply With Quote
Old 04-27-2004, 09:00 AM   #4 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,530
sde is on a distinguished road
thanks. currently i'm the only code monkey for this project, .. but i'm sure i'll be recruiting others as it grows .. so it looks like it's time to get over the escaped scripting style i am working with and get down to the beans.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 12:58 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting