• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best Practice and proper syntax

 
K Robert
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I capture a jsp value in a function such as:


From a best practice standpoint, should I capture this is a variable name or is this acceptable? Secondly, if I wanted to perform an if/else inside this function and on a particular value, do I just wrap the value in an if/else in side the getInfo()? Or, do I create an in-body <script> to run the logic there?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this would be more appropriate in the JSP forum. So moved.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65216
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by K Robert:
should I capture this is a variable name or is this acceptable?


I do not understand your question because you're not being very precise. What kind of variable are you talking about? Client-side or server-side?

Secondly, if I wanted to perform an if/else inside this function and on a particular value, do I just wrap the value in an if/else in side the getInfo()? Or, do I create an in-body <script> to run the logic there?


Again, not clear. You wouldn't nest a <script> tag inside another. Are youtalking about a client-side conditional, or a server-side conditional? If the former, just use the JavaScript if statement. Why the confusion?

If it's the mixing of JSP with JavaScript that's confusing you. Just remember that any JSP elements will be evaluated on the server in order to format an HTML page to be sent to the browser. So any part of the page that's not a JSP element gets treated just like any other old-fashioned HTML page.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic