on 06-02-2008 10:51 AM
Hi all,
I am a novice in java.
I am working on a synchronous scenario .I am working on NWDS. i have developed a web module project in the same i have generated a java class which calls a webservice(suggestions as to how a java class can send a request to a webservice and obtain response from the same are welcome)
I hav developed a jsp and i want to know how i can call the method implemented in my java class. i dont need to pass any parameters to my java class test.java .I just need to call it on the click of a button and i need to view the response from the webservice on the JSP.
please suggest how this can be achieved.
thanks in advance.
.
Hi ,
Here is the solution .
<%@ page import="package.class"%>
and then inside instantiate an object
<%
MyClass mc = new MyClass(parameters if any);
mc.theMethodYouWantToCall();
%>
or
use the JSP tags
<jsp:useBean id="anyname" class="classname"/>
and use get property tag .
Or Use Custome tags .
Regards ,
venkat
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
It's easy.
Put your class (or classes) into the WEB-INF/classes folder. If you are using NetWeaver Developer Studio, just drop it there. Then you can call your class and its methods from the JSP as follow (let's assume your fully qualified class name is org.acme.common.Tool):
<%@page import="org.acme.common.*"%>
...
<%
Tool t = new Tool();
t.doSomething();
%>
...
If you need to call it on a button click, then you might use a port/get parameter for this purpose. For example:
<%@page import="org.acme.common.*"%>
...
<%
// check if the parameter "clickMe" has value "please",
// i.e. if the form was submitted
if ("please".equals(request.getParameter("clickMe"))) {
Tool t = new Tool();
t.doSomething();
}
%>
...
<form method="POST">
<input type="hidden" name="clickMe" value="please">
<input type="submit" value="Go!">
</form>
...
Is that what you need?
Kind regards,
Tsvetomir
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.