473,804 Members | 3,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to pass parameters to jsp

53 New Member
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.sql.*;"%>
  3. <%@ page session="true"%>
  4. <%!String un,per=null;%>
  5. <%
  6.         per=(String)session.getValue("per");
  7.         if(per==null)
  8.         {
  9.         }
  10.         else
  11.         {
  12.             out.println(per);
  13.         }
  14.         un=(String)session.getValue("un");
  15.         Connection con;
  16.         Statement st;
  17.         ResultSet rs;
  18.     try{
  19.         Class.forName("com.mysql.jdbc.Driver").newInstance();
  20.  
  21.         con=DriverManager.getConnection("jdbc:mysql://localhost/experience","root","");
  22.         st=con.createStatement();
  23.         /*if(!isNull(per))
  24.         {
  25.             rs=st.executeQuery("Select EmpName from empdata");
  26.         }*/
  27.         }
  28.         catch(Exception e)
  29.         {
  30.             out.println(e);
  31.         }
  32. %>
  33. <html>
  34.     <head>
  35.         <link rel="stylesheet" href="./css/Form.css">
  36.         <script language="javascript">
  37.         function per(String val)
  38.         {
  39.             document.f1.per.value=val;
  40.         }
  41.     </script>
  42.     </head>
  43.     <body id="body">
  44.     <%out.println("User is <b>"+un+"</b><a href='./LoginForm.html' target='body'><font size=1>(LOGOUT)</font></a>");
  45.     %>
  46.     <h1><center>Welcome To Admin Page</center></h1>
  47.     <h3>Click here to display all the employees</h3>
  48.     <form name="f1">
  49.         <input type="hidden" name="per">
  50.         <center>
  51.             <table>
  52.                 <tr>
  53.                     <td><a href="./Admin.jsp" onclick=per("A")>A</a>|</td>
  54.                     <td><a href="./Admin.jsp" onclick=per("B")>B</a>|</td>
  55.                     <td><a href="./Admin.jsp" onclick=per("C")>C</a>|</td>
  56.                     <td><a href="">D</a>|</td>
  57.                     <td><a href="">E</a>|</td>
  58.                     <td><a href="">F</a>|</td>
  59.                     <td><a href="">G</a>|</td>
  60.                     <td><a href="">H</a>|</td>
  61.                     <td><a href="">I</a>|</td>
  62.                     <td><a href="">J</a>|</td>
  63.                     <td><a href="">K</a>|</td>
  64.                     <td><a href="">L</a>|</td>
  65.                     <td><a href="">M</a>|</td>
  66.                     <td><a href="">N</a>|</td>
  67.                     <td><a href="">O</a>|</td>
  68.                     <td><a href="">P</a>|</td>
  69.                     <td><a href="">Q</a>|</td>
  70.                     <td><a href="">R</a>|</td>
  71.                     <td><a href="">S</a>|</td>
  72.                     <td><a href="">T</a>|</td>
  73.                     <td><a href="">U</a>|</td>
  74.                     <td><a href="">V</a>|</td>
  75.                     <td><a href="">W</a>|</td>
  76.                     <td><a href="">X</a>|</td>
  77.                     <td><a href="">Y</a>|</td>
  78.                     <td><a href="">Z</a>|</td>
  79.                 </tr>
  80.             </table>
  81.         </center>
  82.     </form>
  83.     </body>
  84. <html>
  85.  
  86.  
if i tried like this i am not getting the correct. can any one tell where i am doing mistake

regards



regards
Apr 16 '07 #1
1 2919
r035198x
13,262 MVP
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ page import="java.sql.*;"%>
  3. <%@ page session="true"%>
  4. <%!String un,per=null;%>
  5. <%
  6.         per=(String)session.getValue("per");
  7.         if(per==null)
  8.         {
  9.         }
  10.         else
  11.         {
  12.             out.println(per);
  13.         }
  14.         un=(String)session.getValue("un");
  15.         Connection con;
  16.         Statement st;
  17.         ResultSet rs;
  18.     try{
  19.         Class.forName("com.mysql.jdbc.Driver").newInstance();
  20.  
  21.         con=DriverManager.getConnection("jdbc:mysql://localhost/experience","root","");
  22.         st=con.createStatement();
  23.         /*if(!isNull(per))
  24.         {
  25.             rs=st.executeQuery("Select EmpName from empdata");
  26.         }*/
  27.         }
  28.         catch(Exception e)
  29.         {
  30.             out.println(e);
  31.         }
  32. %>
  33. <html>
  34.     <head>
  35.         <link rel="stylesheet" href="./css/Form.css">
  36.         <script language="javascript">
  37.         function per(String val)
  38.         {
  39.             document.f1.per.value=val;
  40.         }
  41.     </script>
  42.     </head>
  43.     <body id="body">
  44.     <%out.println("User is <b>"+un+"</b><a href='./LoginForm.html' target='body'><font size=1>(LOGOUT)</font></a>");
  45.     %>
  46.     <h1><center>Welcome To Admin Page</center></h1>
  47.     <h3>Click here to display all the employees</h3>
  48.     <form name="f1">
  49.         <input type="hidden" name="per">
  50.         <center>
  51.             <table>
  52.                 <tr>
  53.                     <td><a href="./Admin.jsp" onclick=per("A")>A</a>|</td>
  54.                     <td><a href="./Admin.jsp" onclick=per("B")>B</a>|</td>
  55.                     <td><a href="./Admin.jsp" onclick=per("C")>C</a>|</td>
  56.                     <td><a href="">D</a>|</td>
  57.                     <td><a href="">E</a>|</td>
  58.                     <td><a href="">F</a>|</td>
  59.                     <td><a href="">G</a>|</td>
  60.                     <td><a href="">H</a>|</td>
  61.                     <td><a href="">I</a>|</td>
  62.                     <td><a href="">J</a>|</td>
  63.                     <td><a href="">K</a>|</td>
  64.                     <td><a href="">L</a>|</td>
  65.                     <td><a href="">M</a>|</td>
  66.                     <td><a href="">N</a>|</td>
  67.                     <td><a href="">O</a>|</td>
  68.                     <td><a href="">P</a>|</td>
  69.                     <td><a href="">Q</a>|</td>
  70.                     <td><a href="">R</a>|</td>
  71.                     <td><a href="">S</a>|</td>
  72.                     <td><a href="">T</a>|</td>
  73.                     <td><a href="">U</a>|</td>
  74.                     <td><a href="">V</a>|</td>
  75.                     <td><a href="">W</a>|</td>
  76.                     <td><a href="">X</a>|</td>
  77.                     <td><a href="">Y</a>|</td>
  78.                     <td><a href="">Z</a>|</td>
  79.                 </tr>
  80.             </table>
  81.         </center>
  82.     </form>
  83.     </body>
  84. <html>
  85.  
  86.  
if i tried like this i am not getting the correct. can any one tell where i am doing mistake

regards



regards
You can put the value in a hidden input and retrieve using request.getPara meter
Apr 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

110
9972
by: Mr A | last post by:
Hi! I've been thinking about passing parameteras using references instead of pointers in order to emphasize that the parameter must be an object. Exemple: void func(Objec& object); //object must be an object instead of
7
21643
by: Zlatko Matić | last post by:
Let's assume that we have a database on some SQL server (let it be MS SQL Server) and that we want to execute some parameterized query as a pass.through query. How can we pass parameters to the server ? Is it possible to use parameters in pass-through queries ? An additional question: Is it possible to connect to a database on MySQL or PostgreSQL using ADO ? Is it possible to execute pass-through queries with parameters, using ADO...
3
2751
by: Zlatko Matić | last post by:
Hello. I'm wondernig what is happennig whith saved pass-through queries nested in regular JET query if regular JET query just filtrates result by start/end date...Does pass-through query first returns all rows from server and then JET filtrates result by start/end date, or JET first communicates with server so that server returns only those rows that JET query would return after filtering by start/end date criteria ? For example, let's...
0
3326
by: Zlatko Matić | last post by:
Hi everybody! Recently I was struggling with client/server issues in MS Access/PostgreSQL combination. Although Access is intuitive and easy to use desktop database solution, many problems appear when someone is trying to use it as front-end for real server database systems such as PostgreSQL or MySQL. One of these problems is regarding pass-through queries and parameters. I wanted to have all the code on client, while executing it on...
2
17112
by: Alex Nitulescu | last post by:
Hi. I have tried to pass two parameters, like this: Response.Redirect(String.Format("NewPage.aspx?Username={0}, Pass={1}", txtUserName.Text, txtPass.Text)) But if I pass Username="Alex" and Pass="AAA", I get Params("Username") = "alex, Pass=AAA" and Params("Pass")="", which is not what I expected.
5
10160
by: cpnet | last post by:
I'm able to pass string parameters with no problems to a LocalReport being displayed by the ASP.NET ReportViewer control. However, my report also has a DateTime parameter. LocalReport.SetParameters(..) only seems to allow me to set string parameters. Is there a way to pass DateTime (or other types) of parameters? Or can I only use string parameters in a LocalReport if I need to pass them in from my ASP.NET app? Thanks, cpnet
0
2113
by: PriyaManasarovar | last post by:
Can someone help how to pass parameters to a crystal report using a Crystal report object? I am using a console application & hence crystal report viewer cannot be used. And i need to pass the parameter through a batch file at run time? I have included a code here to pass parameters, but its giving invalid index error when i try to pass parameters: report1 = app.OpenReport(sfilename) crxDatabase = report1.Database ...
4
9125
by: kinaxx | last post by:
Hello, now I'm learning progamming language in university. but i have some question. in textbook. says there are four passing Mechanism 1) pass by value (inother words : call by value) 2) pass by reference (inother words: call by reference) 3) pass by value-result <- i have question this subject . 4) pass by name
2
3219
by: gumby | last post by:
I would like to call this stored procedure, but I am unable to pass parameters to the @Start and @End. Is thier a way to pass parameters to a pass through query from MS Access? SELECT COUNT(dbo.tblPersActionHistory.PersActionID) AS , .fn_FindStartPayPeriod(dbo.tblPersActionHistory.PersActionID, 2) AS FROM dbo.tblPersActionLog INNER JOIN
12
11119
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms. Here is a newbie mistake that I found myself doing (as a newbie), and that even a master programmer, the guru of this forum, Jon Skeet, missed! (He knows this I'm sure, but just didn't think this was my problem; LOL, I am needling him) If...
0
9708
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10589
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10327
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10085
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9161
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5527
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4302
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3828
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.