Author | Message |
---|---|
jkerby
Posts: 12
|
Posted 00:47 May 11, 2013 |
Hi All, I am having two problems. 1. I am having trouble doing logic on the session variable user name. I can see the value of the session variable on the new page for on the new page I have not been able to figure out how to check if it is NULL. I am working on the portion the shows a Log in or Log out link. Do I put this code on the .jsp page or .java page? I am confused. 2. I have an array of strings in my .java class for genres of games. I can display them with c:out but when I want to use the array to populate a drop down box I can not use c:out. How do I got about using a string array that is in a .java file with a ,jsp page? Thanks. J. |
jkerby
Posts: 12
|
Posted 00:56 May 11, 2013 |
Currently for 1:) I am using if (empty sessionScope.name} What are peoples opinion on this usage? This currently works but is this the best/correct way of doing this? Thanks. |
cysun
Posts: 2935
|
Posted 09:45 May 11, 2013 |
To check if a session variable is null in JSP:
To use an array of String in JSP to create a drop-down list, first of all the array has to be accessible by the JSP, which means the array should be in application or session or request scope, and then do something like:
|
jkerby
Posts: 12
|
Posted 19:56 May 11, 2013 |
I am still having an issue with the string array. I have not been able to do logic or see the value of each element in the array when doing this way. I can only see the value of each element when I use a for each loop and use <c:out value="${genre}"/> in a simple <p> or something. I know the values are getting to the .jsp. I read somewhere online it has to do with the fact that since it is a string array you HAVE to use c:out, is this true? |
cysun
Posts: 2935
|
Posted 00:20 May 12, 2013 |
When in doubt, do a simple example. As you can see here, there's no need for <c:out>. |