I have one jsp
file named test.jsp
.
I want to make link to a function which is in another jsp
file named test2.jsp
.
My test.jsp has the following code:
<%@ page import="java.sql.*" %>
<% Class.forName("com.mysql.jdbc.Driver"); %>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H1></H1>
<%
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/xmldb", "root", "root");
Statement statement = connection.createStatement() ;
ResultSet resultset = statement.executeQuery("select DISTINCT title from categoryInfoTable") ;
%>
<TABLE>
<% while(resultset.next()){ %>
<TR>
<TD>
<a href="test1.jsp?value1=<%=resultset.getString(1)%>"><%=resultset.getString(1)%></a>
</TD>
</TR>
<% } %>
</TABLE>
</BODY>
</HTML>
And my test2.jsp
code is as follows:
<%@ page import="java.sql.*" %>
<% Class.forName("com.mysql.jdbc.Driver"); %>
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<H1></H1>
<%
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/xmldb", "root", "root");
Statement statement = connection.createStatement() ;
ResultSet results = statement.executeQuery("select Images from categoryConfigTable where parentCID = 20 && sequenceNum = 1;") ;
%>
<%
String req_received= request.getParameter("value1");
if(req_received=="Images")
{
while(results.next()){ %>
<TABLE>
<TR>
<TD>
<a href="<%=results.getString(1)%>.jsp"><%=results.getString(1)%></a>
</TD>
</TR>
</TABLE>
<% }} %>
</BODY>
</HTML>
when i run test.jsp
i get multiple links as it was supposed to be.
And when i click on Images it goes to URL
http://localhost:8080/media/test1.jsp?value1=Images
But it doesn't show anything on this page. Why so? Is my code wrong anywhere. Please help me.