how to create a function in jsp

1.8k Views Asked by At

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.

1

There are 1 best solutions below

2
On

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..