1

I have created a web page called allmeters.jsp. In the page I have a hyper link

<a href="demo.jsp?mid=<%=rs.getInt("meterid")%>"><%=rs.getInt("meterid")%></a>

In my second page called demo.jsp, I have one label and search button and I am accessing the label value from allmeters.jsp by using

<label name="name1" value="<%=request.getParameter("mid")%>">
     <font size="4">Meter ID : <%=request.getParameter("mid")%></font>
</label>

I am getting mid value from allmeters.jsp.

Now the problem is by using mid value I want to retrieve the data from MySql table after clicking on button. How to create a function in JSP and how to call that function in a button using JSP.

Alexis Pigeon
  • 7,423
  • 11
  • 39
  • 44
Sai Sai
  • 115
  • 2
  • 4
  • 17

1 Answers1

0

Well, just pass the mid value first to a servlet instead of passing it to a jsp directly. And run your query there using mid value and send the result in a arraylist or something according to your result to demo.jsp and then print them.

or

you can simply use scriptlets itself in the page to create your function and get the values..But i don't suggest you to do that..Try first method instead..

  • Thanks ankit.but can you please explain me how to include a function in jsp and how to call that function on clicking on search button because i a am very new to jsp. – Sai Sai Oct 20 '12 at 07:39
  • ok..Well sorry but above code doesn't make that clear to me about the whole problem..I mean by which button you want to call that function..Paste the whole code then let's see what can be done..because from here i can only understand that you want to call function on the hyperlink click..Is it so?? – Ankit Chhajed Oct 20 '12 at 11:19