• Post Reply Bookmark Topic Watch Topic
  • New Topic

When not use JSP  RSS feed

 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello:
In the J2EE application, we use JSP in the pretation tier. But it's better to use JavaScript quite often. Because JavaScript can be used to validate data before it is submitted to a server, this will save the server from extra processing. Is there any other reasons that we have to use avaScript in J2EE app.? If we use JavaScript, we have to install the JavaScript on each client?
Thanks!
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

In the J2EE application, we use JSP in the pretation tier. But it's better to use JavaScript quite often.

JSP and Javascript serve very different roles in the presentation tier. JSP is used on the server side to dynamically format the HTML reponse to be sent to the browser. Once loaded into the browser, Javascript can be used to manipulate the page on the client side.

Because JavaScript can be used to validate data before it is submitted to a server, this will save the server from extra processing.

It would not be a very good idea to ever assume that client-side validation has taken place. Your data should always be validated on the server side regardless of whether your pages have client-side validation or not (why? Javascript can be disabled, or malicious users can submit URLs directly)

Is there any other reasons that we have to use avaScript in J2EE app.?

Only if you want to perform client-side operations on your pages.

If we use JavaScript, we have to install the JavaScript on each client?

Javascript interpreters are built into the browsers.
[ February 02, 2004: Message edited by: Bear Bibeault ]
 
sarah Marsh
Ranch Hand
Posts: 282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Bear.
So we should avoid using Javascript in this case, right? Is there any benefit to use Javascript at all when build J2EE app.?
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I personally see no benefit of using javascript. I'm not saying that it's not useful, but the client can easily disable it and skip it, as Bear said.
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree that validating business logic on the client with javascript is not a good idea. If you want to pre-validate fields that's fine, as it might help the server with expediency, but don't rely on it. If you need javascript to help your presentation, such as button rollovers, popups, etc sure, go for it. But design so that if javascript is turned off it doesnt affect your application.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript is not offically related to J2EE in any way. It just happens to be able to be output from the presentation tier. Personally we try not to use JavaScript at all. The only real application of JS is to make the site a bit prettier, cleaner, or easier to use for the client.
Examples of this are drop-down menus or image roll-overs and dynamically updated (ie client-side) HTML elements.
A big disadvantage of JS - and this extends the point made by Bear - is that it starts to push the application logic on to the client. You start to run the risk of having your business logic spread across two tiers, or implementing the logic twice - once in Java, once in JavaScript - then trying to maintain both.
You'll have to check how this works in your particular case, but we tend to keep page sizes fairly small and encourage images to be cached. This reduced the overhead of doing everything on the server. If you're finding that processing is having a noticable effect on the server, it's often cheaper to upgrade hardware than fix the problem!
Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66144
144
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Louis, your contribution is very much appreciated, and I hate to throw cold water on you, but it must be pointed out that your display name doesn't conform to Ranch standards. Please reference your previous two warnings here.
bear
JSP Forum Bartender
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Bear Bibeault:
Hi Louis, your contribution is very much appreciated, and I hate to throw cold water on you, but it must be pointed out that your display name doesn't conform to Ranch standards. Please reference your previous two warnings here.
bear
JSP Forum Bartender

It's also worth mentioning that accounts with invalid display names get deleted, often without warning. 23 posts is on the verge of being deleted at any stage. Also, we tend to delete the accounts and only then try to contact the user. Sad but true
Dave
 
Ben Dover
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not so much pouring cold water as a wet blanket.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!