Results 1 to 3 of 3
- 10-23-2008, 09:07 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
How to call method in servet by using JSP?
can anybody give me example code to call the data from servlet class and view using presentation layer JSP...
If i created servlet called showservlet.java which it have the connection and query statement to select the data from database (select * from abc). How i call it by view it using JSP..view.jsp.
- 10-23-2008, 10:17 AM #2
Member
- Join Date
- Oct 2008
- Location
- Sweden, Gothenburg
- Posts
- 21
- Rep Power
- 0
Try thinking of the JSP as an ordinary java class with super-powers. How would you call a method in another class?
First you would have to import that class. In java you would type:
import se.frank.com.ShowServlet;
In a JSP, you type:
<%@ page import="se.frank.com.ShowServlet" %>
After that it's as simple as
<%= ShowServlet.getSuffFromDatabase() %>
to print whatever ShowServlet.getStuffFromDatabase() returns.
Mind you, the class ShowServlet is not actually treated as a servlet here. I'm sort of assuming you are misusing the word 'servlet' here as there is generally no reason for mixing servlets and jsp pages.
- 10-24-2008, 04:20 AM #3
Member
- Join Date
- Oct 2008
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
[SOLVED] Call method from another class name
By antgaudi in forum New To JavaReplies: 3Last Post: 10-15-2008, 12:33 AM -
Need to dynamicaly get all parameters in a method call.
By DavidJohns in forum Advanced JavaReplies: 2Last Post: 05-21-2008, 07:15 AM -
Call Java Method
By hussainzim in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 05-15-2008, 07:22 AM -
cannot call private method from static method
By jon80 in forum New To JavaReplies: 3Last Post: 05-07-2008, 08:37 AM -
Call a Method Automatically
By rhm54 in forum New To JavaReplies: 4Last Post: 02-07-2008, 08:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks