Venkat Raman
Venkat Raman

Reputation: 103

call a function in servlet through jsp url

I'm trying to sort a field for which i call a servlet(index.java) using a hyperlink from my jsp file (index.jsp).. When the user clicks the heading (which is "ID") the sort() function should be called from the servlet and should get sorted. additional info: i collect the elements from the database in index.java and print it on the index.jsp page using the requestdispatcher object.

Upvotes: 2

Views: 776

Answers (1)

Naved
Naved

Reputation: 4138

According to me you can not call a method of the servlet directly from the JSP.
One thing you can do is you can call a servlet which in its service() method do the sorting for you and returns the same structure data (but now in sorted mode) to the JSP.

You can call this using AJAX (which refreshes the part of that page only) or by refreshing the the whole page.

Upvotes: 1

Related Questions