PDA

View Full Version : how to pass parameters to jsp



janunme
04-16-2007, 07:07 AM
hi to all,


in my jsp page hyper links are there starting from "A" to "Z". when ever i click on any one of those links it should call itself and pass a parameter of its value. for example if i click on "A" same page should display once again with a parameter "A". how to do it. i am also sending some code also




<%@ page import="java.sql.*;"%>
<%@ page session="true"%>
<%!String un,per=null;%>
<%
per=(String)session.getValue("per");
if(per==null)
{
}
else
{
out.println(per);
}
un=(String)session.getValue("un");
Connection con;
Statement st;
ResultSet rs;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();

con=DriverManager.getConnection("jdbc:mysql://localhost/experience","root","");
st=con.createStatement();
/*if(!isNull(per))
{
rs=st.executeQuery("Select EmpName from empdata");
}*/
}
catch(Exception e)
{
out.println(e);
}
%>
<html>
<head>
<link rel="stylesheet" href="./css/Form.css">
<script language="javascript">
function per(String val)
{
document.f1.per.value=val;
}
</script>
</head>
<body id="body">
<%out.println("User is <b>"+un+"</b><a href='./LoginForm.html' target='body'><font size=1>(LOGOUT)</font></a>");
%>
<h1><center>Welcome To Admin Page</center></h1>
<h3>Click here to display all the employees</h3>
<form name="f1">
<input type="hidden" name="per">
<center>
<table>
<tr>
<td><a href="./Admin.jsp" onclick=per("A")>A</a>|</td>
<td><a href="./Admin.jsp" onclick=per("B")>B</a>|</td>
<td><a href="./Admin.jsp" onclick=per("C")>C</a>|</td>
<td><a href="">D</a>|</td>
<td><a href="">E</a>|</td>
<td><a href="">F</a>|</td>
<td><a href="">G</a>|</td>
<td><a href="">H</a>|</td>
<td><a href="">I</a>|</td>
<td><a href="">J</a>|</td>
<td><a href="">K</a>|</td>
<td><a href="">L</a>|</td>
<td><a href="">M</a>|</td>
<td><a href="">N</a>|</td>
<td><a href="">O</a>|</td>
<td><a href="">P</a>|</td>
<td><a href="">Q</a>|</td>
<td><a href="">R</a>|</td>
<td><a href="">S</a>|</td>
<td><a href="">T</a>|</td>
<td><a href="">U</a>|</td>
<td><a href="">V</a>|</td>
<td><a href="">W</a>|</td>
<td><a href="">X</a>|</td>
<td><a href="">Y</a>|</td>
<td><a href="">Z</a>|</td>
</tr>
</table>
</center>
</form>
</body>
<html>



if i tried like this i am not getting the correct. can any one tell where i am doing mistake

regards



regards