jsp on click of javascript

0 Gaurav Garg · September 2, 2014
Hey guys!!
I am developing a project in JSP and i encountered a problem when i tried to run a jsp code on an onclick mouse event...
cant i call a java function in javascript
i came to know that since JSP is a server side language it is compiled all at once...
Someone plzz help me solve this

Post a Reply

Replies

Oldest  Newest  Rating
+1 Franz Schmidt · September 2, 2014
Could you please post your sample, so we can see what you want to do? :ermm:
0 Gaurav Garg · September 3, 2014
<%
int pageno=session.getAttribute("pageno");
while(rs.next() )
                { 
                    {
            name=rs.getString(1);
            url=rs.getString(2);
            desc=rs.getString(8);
            %>
            <tr><td style="border-bottom-color: white; border-bottom-style: dashed;border-bottom-width: thin;"><a href="<%=url%>"><%=name%></a></td></tr>
            <tr><td style="border-bottom-color: white;border-bottom-style: dashed;border-bottom-width: thin;"><label id="label1"><%=url%></label></td></tr>
            <tr><td style="border-bottom-color: white; border-bottom-style: double;"><label id="label2"><%=desc%></label></td></tr>
            
            <%     
                }
  
%>
<input type="button" value="button">


What i want to do is that when i click on the hyperlink 'a',it should -
first,call an update function in another bean class which updates the database and then go to the required hyperlink

and also when i click on the next page button
it performs-
<%
pageno++;
session.setAttribute("pageno");
%>

When i try to do this with javascript,it compiles all the java code all at once and increments pageno at the load time itself.
  • 1

Javascript

107,057 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators