Pessoal, estou com um problema com uma passagem de parâmetro via URL utilizando o método GET em JSP!
O que acontece é o seguinte: tenho um index.jsp que leva o seguinte código:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sistema WEB de Condomínio</title>
</head>
<body>
<table align=center border=1 cellpadding=0 cellspacing=0 bordercolor=red width=760>
<tr>
<td colspan=3><%@ include file='header.jsp' %>
</td>
</tr>
<tr>
<td valign=top><%@ include file='menuleft.jsp'%>
</td>
<td>
<%
String id="";
id = request.getParameter("id");
if (id!="")
{
if (id=="1")
{
%><%@ include file='apartamento.jsp'%><%
}
else
if (id=="2")
{
%><%@ include file='proprietario.jsp'%><%
}
else
if (id=="3")
{
%><%@ include file='despesa.jsp'%><%
}
else
if (id=="4")
{
%><%@ include file='pesquisa.jsp'%><%
}
else
if (id=="5")
{
%><%@ include file='ajuda.jsp'%><%
}
else
{
%><%@ include file='body.jsp'%><%
}
}
else
{
%><%@ include file='body.jsp'%><%
}%>
</td>
<td valign=top><%@ include file="menuright.jsp"%>
</td>
</tr>
<tr>
<td colspan=3><%@ include file="footer.jsp"%>
</td>
</tr>
</table>
</body>
</html>
Eu tenho um menu que carrega as página de acordo com o “id” passado via GET:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Sistema WEB de Condomínio</title>
</head>
<body>
<table border=0 cellpadding=0 cellspacing=0 bordercolor=red width=150>
<tr>
<td>
<table valign=top>
<tr>
<td><font face=verdana size=1>
<a href='index.jsp'>Inicio</a>
</td>
</tr>
<tr>
<td><font face=verdana size=1>
<a href=index.jsp?id=1>Apartamento</a>
</td>
</tr>
<tr>
<td><font face=verdana size=1>
<a href=index.jsp?id=2>Proprietário</a>
</td>
</tr>
<tr>
<td><font face=verdana size=1>
<a href=index.jsp?id=3>Despesa</a>
</td>
</tr>
<tr>
<td><font face=verdana size=1>
<a href=index.jsp?id=4>Pesquisa</a>
</td>
</tr>
<tr>
<td><font face=verdana size=1>
<a href=index.jsp?id=5>Ajuda</a>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
O problema é que ele está carregando apenas a página padrão, que no caso é a “body.jsp”. Mesmo eu clicando nos links que endereçam o “id” a outros valores, a página default é carregada. O que vcs acham que seja isso? Já tentei colocar aspas no valor da variável (i.e. - “<a href=index.jsp?id=“1”>Apartamento”, mas não deu certo. Espero que me ajudem.
Abraço!