How to call java method using jsp
how to call java method using jsp.....
anyone can help me.....i having problem here...coz i very new in java and jsp.....
thanks.....
keep an eye on this person's thread...they have code there and everything.
http://forum.java.sun.com/thread.jspa?threadID=777263&tstart=0
Similar Messages
-
How to call java method in jsp file?
can anyone guide me or teach me how can i call the java method into the jsp file? do i need a main method to call it in? or just call the method that i need 2 use only??
below is the coding that i did. one is java and another one is jsp. hope that someone can help me on it. Thanks!!!! Really appreciate it.
Country Method.java
package Test;
import java.io.File;
import com.db4o.*;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
public class countryMethod {
public final static String filename = "C:\\TestStore.yap";
public String record;
public int value;
public String cName1;
private static ObjectContainer db = Db4o.openFile(filename);
public static void storeData() {
//Delete existing data file
new File(filename).delete();
//Open Database
db = Db4o.openFile(filename);
//Add value into database
Country c1 = new Country(100, "Malaysia");
Country c2 = new Country(200, "Thailand");
Country c3 = new Country(300, "Sing");
Country c4 = new Country(400, "Japan");
Country c5 = new Country(500, "Indian");
db.set(c1);
db.set(c2);
db.set(c3);
db.set(c4);
db.set(c5);
System.out.println("abc");
public String getData() {
String str = "";
try {
//open database
ObjectContainer db = Db4o.openFile(filename);
//Create empty object
Country country = new Country(0,null);
//Object dataset
ObjectSet result = db.get(country);
//System.out.println(result.size());
while(result.hasNext()){
Country a = (Country)result.next();
record = a.getName();
value = a.getValue();
str = str +" | "+ value;
//System.out.println(str);
//System.out.println(a.getValue());
}catch(Exception s){
s.printStackTrace();
str = str +" | "+ record;
return str;
/*public int getValue(){
return value;
}and the jsp.
<%@page import com.db4o.ObjectContainer%>
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="link" class = "Test.countryMethod" />
<%=link.getData() %>
</body>
</html>i try on the easier that i can but still i have error displaying it
here are the files
package com;
public class CountryPeople {
public String name;
private int value;
public CountryPeople(String name, int value){
this.name = "Eric";
this.value = 2;
public String getName() {
return name;
public int getValue(){
return value;
}JSP file will be
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="store" class="com.CountryPeople"/>
<jsp:setProperty name="store" property="name" />
<jsp:setProperty name="store" property="value" />
<%= store.getName() %>
<jsp:getProperty name="store" property="name" />
<jsp:getProperty name="store" property="value" />
</body>
</html>JAVA File
<html>
<head><title>Testing page</titile></head>
<body>
<jsp:useBean id="store" class="com.CountryPeople"/>
<jsp:setProperty name="store" property="name" />
<jsp:setProperty name="store" property="value" />
<%= store.getName() %>
<jsp:getProperty name="store" property="name" />
<jsp:getProperty name="store" property="value" />
</body>
</html>The end message is
the error message
at [org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:869)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:664)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Unknown Source)
Hope that you guys can me. Thanks -
How to access java method in JSP
Hi all,
I need to access java class (abstract portal component) method doContent() in a JSP which is under PORTAL-INF/jsp folder.
I did
<%@ page import = "com.mycompany.Aclass" %>
<%com.mycompany.Aclass a = new com.mycompany.Aclass (); %>
Aclass is coming as autofill/prepopulated with cntrl+space
Till this time, it is working. no errors. But when I do
a.
a. (a dot) no methods are populating (autofill..cntrl+space) or If I forcebly add method a.doContent(req,res)... at runtime its giving error.
It's not only with doContent method... Its with any simple methods in that class or any other class.
(Other than doContent method in the APC java class are prepopulating/autofilling but giving error in runtime)
Can anyone help me... how to access java method in JSP.
I already gone through many SDN forum post... and implemented too---but no use I refered below forum thread
Retrieve values from Java class to JSP
URGENT! How to call a java class from JSP.
Calling a java method from jsp file -
this thread is same as my issue
Thanks,
PradeeP1st. The classes must be in packages. 2nd, the package that they are in must be under the WEB-INF/classes directory. 3rd Look on google and/or this site for web application deployment
-
How to call java method from workflow script?
Hi
I have a requirement of updating field value 'Document Status' based on review/approve of content from Workflow and hence need to update the version number. For that I need to call my java method from workflow during submit of review/approve condition. Please let me know how to call java method from workflow?
Is there any alternative better way to achive this requirement from workflow? Please suggest.
Thanks,
SarangOK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
Solved? -
How to call java method having array as argument from c++ ?
Hello sir,
how to call java method having array as arguments from c++;
here is java code which is called from c++
class PQR {
public void xyz(int[] ia) {
System.out.println("hi");
for (int i = 0; i < ia.length; i++)
System.out.println(ia);
suppose all jvm invocation is done...For someone well versed in java, C++ and JNI although tedious that should be obvious.
For someone not well versed in all three it is going to be very difficult.
Even for someone that does have knowledge in all of those areas coming up with a C++ interface that reflects that functionality in a dynamic way such that anyone is will to use it is going to be quite an adventure.
At any rate to start building it you do exactly the same thing that you would in java.
1. Extract everything in the jar via the zip package
2. For each found instance extract all of the methods, return types, parameters, etc and build a description tree for each class.
Doing all of that in C++ is going to take a LOT of code. If someone wanted an estimate from me it would take me 6 months to do it. And before I would even attempt it I would get them to explain to me in detail exactly how they thought they were going to use it when I was done because I can't see any reasonable way to do that.
I left out the description tree itself. I suppose you could duplicate the entire reflection api in C++.
Now perhaps if it was much, much more constrained, like to only those classes that implement a single interface then that would be more reasonable. -
How to call java method on page load?
How to call java method on page load?
ThanksHey Dan,
Well, if you want to execute a java method when page is load, you need to put the clientlistener in af:document. Let me to show you an example (I can't find my post :P),
JSPX page:
<f:view>
<af:document>
<f:verbatim>
<script>
function loadPage(event) {
alert('Hello World!');
</script>
</f:verbatim>
<af:clientListener method="loadPage" type="load"/>
</af:document>
</f:view>If you try this code you can see that when the page has been load, you recieve the alert "Hello World!".
Furthermore, this is the javascript AJAX function that let you to call a servlet:
function ajaxFunction () {
var httpRequest;
if (window.XMLHttpRequest) {
httpRequest = new XMLHttpRequest();
} else if (window.ActiveXObject) {
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
httpRequest.overrideMimeType('text/xml');
httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
httpRequest.open('GET', '/appname/servletname', false);
httpRequest.send('');
function alertContents(httpRequest) {
if (httpRequest.readyState == 4) {
if (!httpRequest.status == 200) {
alert('Request error. Http code: ' + httpRequest.status);
}Where 'appname' is your application name and 'servletname' is the name of the servlet that you want to call. Obviously, you can call any URL ;)
JVN -
How to call Java methods from a Windows application?
Hello all,
At our company, we need to integrate our product which is a Java Swing application with a Windows application. Specifically, we are trying to call Java methods that reside in our application from the Lotus Notes email client application, which is a native Windows application. Such that when a user clicks a button in the Lotus Notes email client, it will trigger an event in our Swing application. Is this possible using JNI? Do you know of any resources or references relating to this kind of a project?
Thanks,
Mete KuralIf there is some dll interface that lets Lotus Notes load up and use a DLL, then yes, this should be possible.
-
How to call Java method from SAPUI5 applications?
Hi Experts,
Please give me information that how can I call Java method or jars from SAPUI5 applications?
Thanks,
NagHello Nag,
why do open this thread in BRM Space? I would suggest reopen this in "UI Development Toolkit for HTML5 Developer Center" Space.
Regards,
Tobias -
How to call Java method from XSLT??
Hi All,
Jdev 11.1.1.3.0
I have a requirement to implement that, I have to call Java method from XSLT. Could anyone please suggest to implement that??
Thanks,
Santosh M EAs pointed by others, you must expose your method as a custom function, registering with JDeveloper (for development time) as well as with SOA Suite (for runtime).
In the link below you will find a simple step by step example:
https://blogs.oracle.com/reynolds/entry/building_your_own_path
Regards,
Luis F. Heckler -
How to call Java Beans from JSP (eg.put them in a WAR or package)
Can anyone explain to me what are the steps and ways to call java beans from JSP?
1st, put the javabean classes in the right place:
the web-inf/classes/your_bean.class directory of corresponding web application
2nd in your jsp page:
<jsp:useBean id="obj_var_name" class="your_bean"/>
<jsp:setProperty name="obj_var_name" property="smthg" value="smthg_calue"/>
Micheal -
How to call java method from C ?
Hello,
I try to call a native method from java which calls java method from the same class. Exception (noSuchMethodError) is thrown. Any ideas?
Thanx in advance !
here is the source of the native method :
JNIEXPORT jint JNICALL Java_TestDll_Proc_1Mul_1Int_1Var_1Var_1Stdcall (JNIEnv * env, jclass jcl, jint jarg1, jint jarg2) {
int arg1;
int arg2;
int arg3;
jint res;
char * ch = "test";
jfieldID fid;
jmethodID mid;
int (* procedure) (int *, int * ,int *);
int mch;
arg1 = (int )jarg1;
arg2 = (int )jarg2;
procedure = GetProcAddress(libraryHandle,"Proc_Mul_Int_Var_Var_Stdcall");
procedure(&arg1,&arg2,&arg3);
res = (jint) arg3;
printf("(*env)->GetMethodID(env, jcl, \"test\", \"()V\");\n");
mid = (*env)->GetMethodID(env, jcl, "test", "()V");
printf("(*env)->CallVoidMethod(env, jcl, mid);\n");
(*env)->CallVoidMethod(env, jcl, mid);
return res;
here is the source of the java file:
public class TestDll {
static {
System.loadLibrary("testdllwrap");
System.out.println("java: Library testdllwrap.dll loaded");
public TestDll() {
public native int Proc_Mul_Int_Var_Var_Stdcall(int jarg1, int jarg2);
public void test() {
System.out.println("java: test()");
public static void main(String[] args) {
TestDll access = new TestDll();
int a = 5;
int b = 6;
int c = 0;
System.out.println("Calling Proc_Mul_Int_Var_Var_Stdcall");
c = access.Proc_Mul_Int_Var_Var_Stdcall(a,b);
System.out.println("Java Result = " + c);Something is wrong with the code you posted here.
Since your native method is not static, it should have the jobject instance as a parameter in the function prototype, not a jclass. Also, you should be calling CallObjectMethod with a jobject, not jclass.
Check out Jace at http://jace.reyelts.com/jace.
To call the java method you would do:
JNIEXPORT jint JNICALL Java_TestDll_Proc_1Mul_1Int_1Var_1Var_1Stdcall
(JNIEnv * env, jobject jTestDll, jint jarg1, jint jarg2) {
TestDll testDll( jTestDll );
testDll.test();
}God bless,
-Toby Reyelts -
How to call java method from actionscript
I've just now started working on Flex. May be its basic question but I’m not aware of it – how can I call a java method from actionscript. I want to call some java method on double click of a event. Can you please let me know how to proceed on this?
OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
Solved? -
How to call java method from xsl
hi friends,
How to call a java method from xsl, i have a xsl file which will call the java method and retrieve the value and display it to the user. but its work well when i set xalan.jar and xerces.jar and the java class files in my classpath and run as
java org.apache.xalan.xslt.Process -in navigate.xml -xsl nav-exst.xsl -HTML -out navoutpage.html[b]
in the command prompt but when i deploy it as web application it gives error as
[b]Namespace 'MyPack' does not contain any functions[b]OK. So, I think we can all conclude that you don't need to call any Java method, can't we? And, that wfUpdateMetadata is the command that will update your metadata.
Now, the question is what are its arguments. It has two - the first is the name of a custom metadata field to be updated (let's suppose that one field is called xMinorVersion, and the other xMajorVersion), the other is the new value, e.g. <$wfUpdateMetaData("xMinorVersion", "New value.")$>As for new value - do you insist on using strings? Since you want to increase the value, it would be more convenient to work with numbers. For instance, with integers you could go with <$wfUpdateMetaData("xMinorVersion", xMinorVersion + 1)$>With strings you will need to convert it to numbers and back to strings. Besides, what happens if you have more than 100 minor versions? (you mentioned you want to add 0.01, but that would finally increase the major version, wouldn't it?) So, I think these two numbers are independent (perhaps, with exception that increase on the major version set the minor version to .00).
If you want to present it, you can use profiles that will construct for you the representation 2.304 out of MajorVersion = 2, MinorVersion = 304
Solved? -
How to call java bean from jsp
hi
How to call a java bean from jsp page..
Is any other way to call javabean from jsp page apart from this sample code...
<jsp:useBean id="obj" class="com.devsphere.articles.calltag.TestBean"/>
thnx in advanceIf you also use servlets, you can attach beans to the request or session and use them directly in your JSP's. So if you do:
request.setAttribute("name", yourBean);and then forward to a JSP, you can reference the bean like:
${requestScope.name} -
How to call other method using struts
Hi,
in my TestAction.java,
i have 2 method, one is execute(...) and another is changeABC(...)
in jsp,
when i onchange, i call a javascript
function onSwitch()
document.forms[0].action.value = "changeABC";
document.forms[0].submit();
<html:form action="/test.do">
</html:form>
test.do will call TestAction.java and TestActionForm.java.
y when i submit, it keep calling the execute method??
How i suppose to do to enable it call changeABC method??
pls advice.. thankshi
i am sending u one plz reply as soon as possible
Maybe you are looking for
-
Time Machine said it would take 16 days to do an initial backup, and indeed, after many days it is less than a quarter done. (The problem started when I put in a new bank disk for Time Machine to write to for its backup file.) Activity Monitor show
-
[Solved]Dual-Head Setup broken after last Kernelupgrade
Hello, Yesterday I upgraded my from 4.0.2 to 4.0.3 and was kind of surprised when my second display didn't want to show a picture anymore. When booting everything looks good when sudenly one display gets black. It doesn't matter which Desktop I start
-
Emails disappear without sending
I've recently started getting a problem with my iPhone: I write an email, hit 'send', and then the email just disappears. Doesn't get sent, doesn't go into a waiting outbox, just disappears into the ether. It seems to happen when I have a weak (or no
-
I live in brasil but i want Muse in english!? can someone tell me how
i live in brasil but i want Muse in english!? Can someone tell me how & where i can change the language? Thx
-
Re-Install - A real Pain HELP Please!!!!!!!!!!
Hi There I am trying to reinstall Indesign CC however the Creative download app is not seeing it as a new install and then trying to update - can anyone assist. This is a real PAIN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Assistance wo