I'm trying to display an alert based on a request parameter and it is giving me problems.
I'm calling the page as follows
Code:
// check for duplicate Layer name or title
ResultSet rs = DatabaseConnection.Query("SELECT * FROM tblLayers WHERE Layer_Name = '" + request.getParameter("Layer_Name") + "'");
if (rs.next())
{
//duplicate name exists
%>
<script language="JavaScript">
alert("A Layer with this name already exists");
</script>
<%
response.sendRedirect("new_data_registration.jsp?Duplicate=name");
}
else
{
rs = DatabaseConnection.Query("SELECT * FROM tblLayers WHERE Layer_Description = '" + request.getParameter("Layer_Description") + "'");
if (rs.next())
{
//duplicate description exists
response.sendRedirect("new_data_registration.jsp?Duplicate=title");
}
}
rs.close();
This appears to work fine and if the redirect happens I see either
new_data_registration.jsp?Duplicate=name or new_data_registration.jsp?Duplicate=title as the url at the top of the page.
My problem comes when I try to access the Duplicate paramater. I have attempted to get it using
Code:
<%
if (request.getParameter("Duplicate") != null)
{
%>
<script language="JavaScript">
alert("A Layer with this " + <%= request.getParameter("Duplicate") %> + " already exists");
</script>
<%
}
%>
For some reason this displays an alert say "A Layer with this menu already exists" when duplicate = name (Note the msg says menu, not name)
and displays nothing at all when Duplicate = title
Has anyone got any ideas as to what is going on?