Ok, here is all my code:
<%@ page contentType="text/html" %>
<%--//Page Directives --%>
<%@ page language="java" %>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.Document" %>
<%@ page import="org.w3c.dom.Element" %>
<%@ page import="org.w3c.dom.DOMException" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.io.InputStream" %>
<%@ page import="java.io.IOException" %>
<%@ page import="logonBean.*" %>
<%@ page import="java.security.*" %>
<%@ page import="java.util.Hashtable" %>
<%@ page import="java.util.Enumeration" %>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.naming.directory.*" %>
<%@ page import="javax.servlet.*" %>
<%! public String routeURL="logon.jsp";%>
<%! static String[] appnames = new String[40];%>
<%! int n=0; int flag=0; String name1 = ""; String name2 = ""; String parameterValue = ""; String parameterName="";%>
<%-- //HTML Header --%>
<html>
<head>
<title>Main Page</title>
</head>
<h1>LDAP Server Connection</h1>
<body bgcolor="white">
<FORM ACTION=main.jsp METHOD=POST>
<%-- //Init Page --%>
<%
//#E2EFED
Hashtable env = new Hashtable(5, 0.75f);
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
/*
env.put(Context.PROVIDER_URL, "ldap://another address/ou=db.com,o=NetscapeRoot");
*/
env.put(Context.PROVIDER_URL, "ldap://address to server/dc=db,dc=com");
try {
DirContext ctx = new InitialDirContext(env);
SearchControls constraints = new SearchControls();
constraints.setSearchScope(SearchControls.SUBTREE_SCOPE);
//insteadof ou=WebSSO, take user input to determine value into variable
NamingEnumeration results = ctx.search("ou=Application", "(ou=*)&& !(ou=App)", constraints);
//boxname=egcilab*
while (results != null && results.hasMore() && flag==0) {
SearchResult si = (SearchResult)results.next();
String name = si.getName();
StringTokenizer st = new StringTokenizer(name, "=");
while(st.hasMoreTokens()){
name1 = st.nextToken();
name2 = st.nextToken();
appnames[n] = name2;
n++;}
/*Attributes attrs = si.getAttributes();
if (attrs == null) {
//out.println("No attributes <br>");
}else{
for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements()
{
Attribute attr = (Attribute)ae.next();
String attrId = attr.getID();
for (Enumeration vals = attr.getAll();
vals.hasMoreElements();
//out.println(attrId + ": " + vals.nextElement() + "<br>"));
}
}*/
}
flag=1;
//Exception Handling
}//end of try
catch(NamingException e)
{
out.println("Search failed. <br>");
e.printStackTrace();
}
%>
<TR> <TD> Please Choose An Application from the Drop down menu</TD>
<TD> <SELECT NAME=App>
<OPTION>-------Select Value-------</OPTION>
<%
int k=0;
while(appnames[k]!=null){
%>
<OPTION><%=appnames[k]%></OPTION>
<%
k++;
}
%>
</SELECT></TD>
</TR>
<%-- //Page Routing --%>
<INPUT TYPE=SUBMIT VALUE=Submit>
<br><br><br><br>
</FORM>
<HR>
<B>Application selected</B><BR>
<TABLE>
<%
Enumeration parameters = request.getParameterNames();
while(parameters.hasMoreElements()){
parameterName = (String)parameters.nextElement();
parameterValue = request.getParameter(parameterName); %>
<TR>
<%--<TD><%=parameterName%></TD>--%>
<TD><%=parameterValue%></TD>
</TR>
<% }
%>