dynamic drop down list

I am trying to create a drop down list to do some record sorting. This is my code (I am a vb developer that has had to do some java customization so please forgive my crappy code - all i care is that it works.) The drop down needs to display the current sort.

<div align="right">

<table>

<tr>

<td class="textNormal">

Sorted By: <form action="ChangeSorting.jsp?recordView=<jsp:getProperty name='CumulusBean' property='recordView'/>" id="changeSortingForm" target="invisibleFrame" method="POST">

<td>

<select name="uid" size="1" onChange="document.getElementById('changeSortingForm').submit();">

<%if (session.getAttribute( "theUid" ).equals (null)) {

strCheck = ("selected");

}%>

<option value="">

UnSorted</option>

<%if (session.getAttribute( "theUid" ).equals ("{1e58eab1-f625-4d6b-be82-ef0ea493cb7a}")) {

strCheck = ("selected");

}%>

<option value="{1e58eab1-f625-4d6b-be82-ef0ea493cb7a}" ><%=strCheck%> >

Asset Format</option>

<%if (session.getAttribute( "theUid" ).equals ("{af4b2e43-5f6a-11d2-8f20-0000c0e166dc}")) {

strCheck = ("selected");

} %>

<option value="{af4b2e43-5f6a-11d2-8f20-0000c0e166dc}" ><%//=strCheck%>>

Title</option>

<%if (session.getAttribute( "theUid" ).equals ("{a1fb6bfc-8d0d-4ba1-ba6c-9f85364f8050}")) {

strCheck = ("selected");

} %>

<option value="{a1fb6bfc-8d0d-4ba1-ba6c-9f85364f8050}" ><%=strCheck%>>

P Number</option>

<%if (session.getAttribute( "theUid" ).equals ("{d772f661-9242-11d5-b58c-0050baeba6c7}")) {

strCheck = ("selected");

} %>

<option value="{d772f661-9242-11d5-b58c-0050baeba6c7}" ><%=strCheck%>>

Production Title</option>

<%if (session.getAttribute( "theUid" ).equals ("{ac03983f-c124-41aa-8dd1-315cf1879ffa}")) {

strCheck = ("selected");

} %>

<option value="{ac03983f-c124-41aa-8dd1-315cf1879ffa}" ><%=strCheck%>>

Rights</option>

<%if (session.getAttribute( "theUid" ).equals ("{5cada4d3-90df-11d2-8e22-008048fdada5}")) {

stheck = ("selected");

} %>

<option value="{5cada4d3-90df-11d2-8e22-008048fdada5}" ><%=strCheck%>>

Owning Archive</option>

<%if (session.getAttribute( "theUid" ).equals ("{af4b2e3b-5f6a-11d2-8f20-0000c0e166dc}")) {

strCheck = ("selected");

}%>

<option value="{af4b2e3b-5f6a-11d2-8f20-0000c0e166dc}" ><%=strCheck%>>

Credit Line</option>

</select></td>

</form>

<td>

<cumulus:ifSortingDirectionIs direction="ascending">

<a href="ChangeSortingDirection.jsp?recordView=<jsp:getProperty name='CumulusBean' property='recordView'/>&direction=descending"><img src="../images/sort_asc.jpg" border="0"

alt="Sort Ascending"

></a></cumulus:ifSortingDirectionIs>

<cumulus:ifSortingDirectionIsNot direction="ascending">

<a href="ChangeSortingDirection.jsp?recordView=<jsp:getProperty name='CumulusBean' property='recordView'/>&direction=ascending"><img src="../images/sort_des.jpg" border="0"

alt="Sort Descending"

></a> </cumulus:ifSortingDirectionIsNot></td>

</tr>

</table>

</div>

This does work if the page is already loaded however you get an erro if you try and load the page.

I don't see why...

Any help would be appreciated.

[3811 byte] By [diablo686a] at [2007-10-3 4:28:52]
# 1
The code would look less crappy if you had read this before submitting the post: http://forum.java.sun.com/help.jspa?sec=formattingBy the way, what exactly is the problem? I don't understand your explanation.
CeciNEstPasUnProgrammeura at 2007-7-14 22:31:52 > top of Java-index,Java Essentials,Java Programming...
# 2

> The code would look less crappy if you had read this

> before submitting the post:

> http://forum.java.sun.com/help.jspa?sec=formatting

>

> By the way, what exactly is the problem? I don't

> understand your explanation.

> The code would look less crappy if you had read this

> before submitting the post:

> http://forum.java.sun.com/help.jspa?sec=formatting

>

> By the way, what exactly is the problem? I don't

> understand your explanation.

I am trying to customize a image management solution called Cumulus. When you do a search you get a result set that is unordered. In order to see it in a list format, you can pick a sort parameter via a drop down list. The tags built into the solution produce a drop down with about 20 options. My manager only wants eight of them to be displayed. I created this statically but the drop down doesn't display the current selection.

I pass a parameter to the search page and then populate a session variable so I have access to the parameter globally:

String strUid = request.getParameter( "uid" );

session.setAttribute( "theUid", strUid );

I then use this value and compare it to the uids in the drop down and if it matches, i write a "selected" in the HTML so the right sort choice is displayed in the drop down.

I made the changes with the application running, refreshed and it seemed to work however if I close the application ( with the changes) and restart the program, i get an error. i thought originally that it may be because there is no iniial value for uid and this is producing an error.

In asp if there is no value for a session variable, it is treated as null. I don't know if this is the case for JSP.

Thanks,

Luis

diablo686a at 2007-7-14 22:31:52 > top of Java-index,Java Essentials,Java Programming...
# 3

> In asp if there is no value for a session variable,

> it is treated as null. I don't know if this is the

> case for JSP.

This is also the case with JSP. See [url http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpSession.html#getAttribute(java.lang.String)]HttpSession.getAttribute()[/url]

Also reference the [url http://java.sun.com/javaee/5/docs/api/]Java EE API[/url]

tymer99a at 2007-7-14 22:31:52 > top of Java-index,Java Essentials,Java Programming...