File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes which one is a good Practice? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "which one is a good Practice?" Watch "which one is a good Practice?" New topic

which one is a good Practice?

Ranjith R

Joined: Sep 18, 2001
Posts: 22
Howdy ...reader..
this topic is rather about Style or Practice in JSP: Plz read the piece of codes below.
<h3>Agent name is :</h3>
   out.println("<b>James Bond</b>");
   out.println("<b>Jennifer Lopez</b>");
<h3>Agent Name is:</h3>
<%  if(agentCode.equals("007")){
<b>James Bond</b>
<%  }
<b>Hanibal Lector</b>
... uh...

SO... what do you say? ..

Take care

Take care<BR>r@njith
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Personally: always the second one.
Additionally, the bold tags are common so I'd pull them out as well (separate content and mark-up)

Shama Khan
Ranch Hand

Joined: Aug 14, 2000
Posts: 185
Agreed. I'd say the second one is more correct.

Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
what about:
<h3>Agent name is :</h3>
String strOut;
strOut = "<b>James Bond</b>";
strOut = "<b>Jennifer Lopez</b>";

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Syam Veerakumar
Ranch Hand

Joined: Sep 20, 2001
Posts: 49
Adam Hardy's type of code is always good Practice I guess.

A Quitter Never Wins<br />A Winner Never Quits
Ranjith R

Joined: Sep 18, 2001
Posts: 22
but tell me is it considered as a bad practice if i am using more out.println(someThing) s? rather than stuff like <%=someThing %>
[This message has been edited by Ranjith R (edited October 12, 2001).]
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
"Ranjith R",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at .
We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in again with a new name which meets the requirements.

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
I agree. Here's the link:
subject: which one is a good Practice?
Similar Threads
sequence of form information is not the same WHY???
page refresh problem
Requested Dispatcher
How show page wise Results Displaying in JSP
jsp:forward with jsp:param???