aspose file tools*
The moose likes JSP and the fly likes Total newby JSP if block question is this legal Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Total newby JSP if block question is this legal" Watch "Total newby JSP if block question is this legal" New topic
Author

Total newby JSP if block question is this legal

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
If this block legal

in psdo code its

if(serverName = 'serverProd)
link = somethin1
else if(serverPort = 8080)
link = serverName:serverport
else
link = serverName

Thanks for any help
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
sorry if blocks did not end right is this legal

Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Almost, you have to do the set to the variable, you cannot declare things like "value link" in the middle of the page because that is only text (have you tried your example?) You have to set the value via <c:set tag

Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
Thanks link was only a placeholder I was more interested in getting the if then else block correct
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Well, actually you have a tag that doesn't end (<c:when test="${pageContext.request.serverPort}"> ) and a </c:otherwise> that doesn't close anything (line 19)

It's also a bit weird that param.number can have value serverProd or 8080, seems somehow strange.

For only two conditions I would use c:if instead of <c:choose, check this:

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

Remember that you can have as many when's as you like.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579

Cheers I got confused by an examples if you only doing one check when if you are doing a if/else blocl

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61426
    
  67

And remember that you can nest <c:choose> tags inside <c:when> tags.
Tony Evans
Ranch Hand

Joined: Jun 29, 2002
Posts: 579
The finished working product, its a choose within a choose


Sai Hegde
security forum advocate
Ranch Hand

Joined: Oct 26, 2010
Posts: 200
    
    1

Please post code within code blocks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Total newby JSP if block question is this legal