File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 556
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: 556
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: 556
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: 60048
    
  65

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: 556

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: 60048
    
  65

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

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


Sai Hegde
security forum advocate
Ranch Hand

Joined: Oct 26, 2010
Posts: 198

Please post code within code blocks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Total newby JSP if block question is this legal
 
Similar Threads
Best choice for pagination?
Nesting JSTL Tags
JSTL tags and test conditions
Implementation of google charts in JSP
Struts display:column when/otherwise