• Post Reply Bookmark Topic Watch Topic
  • New Topic

Designing JSPs

 
Wilson Gordon
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far, in most of my JSP files that require data from database, I first invoke a servlet which retrives the data from database and sets the necessary objects for the JSP to use. For this reason, they usually have a .do extension. The JSP pages are all scriptless using EL and JSTL. I haven't defined any custom function or custom tag myself yet.

Am I doing this right? I was thinking that, perhaps I really should define some custom functions myself and use them in the JSP files to set attributes, so some of them don't need to go thru the servlets first.

Thanks in advance for your advice and tips.
[ May 05, 2007: Message edited by: Wilson Gordon ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so some of them don't need to go thru the servlets first.


You're doing it right -- don't regress back to Model 1 now that you're already using a Model 2 pattern.
 
Wilson Gordon
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi bear,

Thanks for the quick reply.

I have seen some JSP sites that shown lots of dynamic data on .jsp pages. Do they just give the servlet URL .jsp extension, or maybe they didn't use scriptless JSP and have Java codes embedded in the .jsp files?
[ May 05, 2007: Message edited by: Wilson Gordon ]
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, some sites do that, but it's not good practice. As Bear said, that's Model 1, which is very ... umm ... 20th century. Web application architecture had moved on since then.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Am I doing this right? I was thinking that, perhaps I really should define some custom functions myself and use them in the JSP files to set attributes, so some of them don't need to go thru the servlets first.


You are doing it right. Remove as much from the JSP that does not belong there.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65530
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Wilson Gordon:
or maybe they didn't use scriptless JSP and have Java codes embedded in the .jsp files?


Unfortunately, you still see a lot of that. Don't use that as a model for your own apps. As you can see, the more experienced people posting here recommend a strong Model 2 implementation with scriptless JSPs. Your life will be better for it!

This article may help with some perspective.
 
Wilson Gordon
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's a good article. Thanks.

I noticed there hasn't been any new journal editions since July 2006. Hopefully you guys have plan to revive it....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!