Call Pageflow-Methods in a Java-Expression
Hi!
In Workshop 9.2b, is there a possibility to call a Pageflow-Method with parameters like the following code?
<%= pageFlow.getValue("sample") %>
There is no object "pageFlow", but is it possible to get it from the pageContext?
thanks,
Josef
Hi Vimala
I got it working by the following workaround:
In the onCreate-Method of my PageFlowController, I store the current PageFlow into the Session:
protected void onCreate() {
getSession().setAttribute("currentPageFlow", this);
in the JSP, I added an import for my PageFlowController:
<%@ page import="mypackage.MyPageFlowController"%>
and used the following java-expression to call my method:
<%= ((MyPageFlowController)session.getAttribute("currentPageFlow")).getText("sample") %>
this works fine.
Thanks,
Josef
Similar Messages
-
How to call the method from the java bean and pass it to JSP textbox
i'm quite new to java thats why i'm asking how to call a method in the java bean file and pass it to the JSP textbox. My projects are communicating JSP with C#. i had successfully created a C# client bean file for JSP. The whole process is to type something on the server(C# programming) and it would appear in the textbox.
your question doesn't provide much informartion. provide some other information and coding so that we could tell exactly what you are looking for?
-
Calling OCX Methods from a Java Program
Hi All,
Is it possible to call OCX methods from a Java program? If yes, can you please refer me to any documents or sample code to achieve this.
All inputs are highly appreciated.
Thanks
TarekJNI
http://java.sun.com/docs/books/tutorial/native1.1/index.html -
Calling a method from another Java file.
I think I'm doing this right, but I'm obviously going wrong somewhere.
In order to not have one big long java file, I've created one main one to execute the program, and another to do some of the functions. I'm using eclipse, btw.
In the main file, I have
currentTB = getActiveTB(playerArea);If it works, it should get send the player area variable to the getActiveTB method, and store the value it returns in the currentTB variable, right?
In the other file, I have;
package scenes;
public class sceneIndex {
private TerrainBlock getActiveTB(String areaCode) {
TerrainBlock tBlock = new TerrainBlock();
**DOES STUFF**
return tBlock;
}I have it set up so the second file is in the source folder "resources" and the package "scenes." The problem is I'm not calling it properly. I'm missing something simple, I think. The only error I'm getting is;
The method getActiveTB(String) is undefined...
Where am I screwing up?
EDIT: Yeah, I'm a rookie here trying to figure it out on my own. My computer science courses, so far, conveniently all consist of just one big java file. Easier to write, sure, but not very efficient/organized.
Message was edited by:
SuckerPunchYeah, so this is still pissing me off. I'm not sure what else to do. I've tried this a million different ways, in both eclipse and netbeans. Whatever. Here's the code, I'd love it if someone could point out the boneheaded mistake I'm making. I'm getting a little frustrated at being stuck on such a simple problem.
Main.javaimport com.jme.app.BaseGame;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.scene.Node;
import com.jme.system.DisplaySystem;
import com.jme.system.JmeException;
import com.jme.util.Timer;
import com.jmex.terrain.TerrainBlock;
import resources.*;
public class Main extends BaseGame {
/* General Variable Declaration */
private String scene; // Tells application which scene to load, default loads default scene
private int width, height, depth, freq; // Creates variables to store information
private boolean fullscreen; // on the user's window
private Camera playerCam; // Defines the main camera for the player, first person view
private Timer timer; // Creates a timer to be used for FPS calculations
private Node currentScene; // The basis for building the scene the player is in
private TerrainBlock currentTB; // This variable holds the current landscape
private String playerArea = new String("initial"); // Contains the string
// code for the scene
// the player is in,
// defaults to the opening scene, unless changed by
// the player loading their game
public static void main(String[] args) {
/* Initializes and Starts the Applications. */
Main app = new Main();
app.setDialogBehaviour(ALWAYS_SHOW_PROPS_DIALOG, Main.class.getClassLoader().getResource("img/spunch.jpg"));
app.start();
protected void update(float interpolation) {
protected void render(float interpolation) {
protected void initSystem() {
* Application initialization properties (window, camera, renderer, key
* bindings, etc)
// Stores variables for window properties
width = properties.getWidth();
height = properties.getHeight();
depth = properties.getDepth();
freq = properties.getFreq();
fullscreen = properties.getFullscreen();
// Assigns renderer and creates game window
try {
display = DisplaySystem.getDisplaySystem(properties.getRenderer());
display.createWindow(width, height, depth, freq, fullscreen);
playerCam = display.getRenderer().createCamera(width, height);
} catch (JmeException e) {
e.printStackTrace();
System.exit(1);
// Sets background to black, should never be seen anyway
display.getRenderer().setBackgroundColor(ColorRGBA.black);
// Initializes the camera
playerCam.setFrustumPerspective(45.0f, (float) width / (float) height,
1, 1000);
Vector3f loc = new Vector3f(250.0f, 100.0f, 250.0f);
Vector3f left = new Vector3f(-0.5f, 0.0f, 0.5f);
Vector3f up = new Vector3f(0.0f, 1.0f, 0.0f);
Vector3f dir = new Vector3f(-0.5f, 0.0f, -0.5f);
// Moves and orients the camera
playerCam.setFrame(loc, left, up, dir);
// Update the camera since it has been changed
playerCam.update();
// Create a timer for FPS updates
timer = Timer.getTimer();
// Assign the camera as the primary display in the application
display.getRenderer().setCamera(playerCam);
// Initialize the escape key as a way to exit the program
KeyBindingManager.getKeyBindingManager().set("exit",
KeyInput.KEY_ESCAPE);
protected void initGame() {
/* Game initialization */
display.setTitle("Slumlords"); // Displays title in window
SceneIndex sIndex = new SceneIndex();
currentTB = sIndex.getActiveTB(playerArea);
currentScene.attachChild(currentTB);
currentScene.updateGeometricState(0.0f, true);
currentScene.updateRenderState();
protected void reinit() {
protected void cleanup() {
}SceneIndex.javapackage resources;
import javax.swing.ImageIcon;
import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.math.Vector3f;
import com.jme.scene.state.TextureState;
import com.jme.system.DisplaySystem;
import com.jme.util.TextureManager;
import com.jmex.terrain.TerrainBlock;
import com.jmex.terrain.util.MidPointHeightMap;
import com.jmex.terrain.util.ProceduralTextureGenerator;
public class SceneIndex {
private DisplaySystem display;
public TerrainBlock getActiveTB(String areaCode) {
TerrainBlock tBlock = new TerrainBlock();
if (areaCode == "initial") {
// Generates random terrain data
MidPointHeightMap heightMap = new MidPointHeightMap (64, 1.0f);
// Scale the data
Vector3f terrainScale = new Vector3f(4, 0.0575f, 4);
// Create the terrain block
tBlock = new TerrainBlock("Terrain", heightMap.getSize(), terrainScale, heightMap.getHeightMap(), new Vector3f(0, 0, 0), false);
tBlock.setModelBound(new BoundingBox());
tBlock.updateModelBound();
// Creating a blended texture based on the height map
ProceduralTextureGenerator pTexture = new ProceduralTextureGenerator(heightMap);
pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/grass.gif")), -128, 0, 128);
pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/dirt.jpg")), 0, 128, 255);
pTexture.addTexture(new ImageIcon(SceneIndex.class.getClassLoader().getResource("img/granite.jpg")), 128, 255, 384);
pTexture.createTexture(64);
// Assigning the texture to the terrain
TextureState tState = display.getRenderer().createTextureState();
Texture t1 = TextureManager.loadTexture(pTexture.getImageIcon().getImage(), Texture.MM_LINEAR_LINEAR, Texture.FM_LINEAR, true);
tState.setTexture(t1, 0);
tBlock.setRenderState(tState);
return tBlock;
}Again, I've tried this a few different ways, and I either get a "Could Not Find Symbol" error referring to the getActiveTB(playerArea); in Main, or it just says java.lang.NoClassDefFoundError: and Exception in thread "main".
Whatever. -
How to expose and call AM methods from plain java (testability etc)?
Hello,
my project is just starting out with the OA Framework. We just encountered our first hurdle - I hope someone here can help out or at least point me in the right direction. None of this stuff seems to be explicitly mentioned in the standard OAF documentation.
This is the situation: We need to call the logic in our Application Modules directly. Two reasons for this:
- We need to expose methods in the AM as web services
- We really want to create unit\integration tests (probably JUnit) and set up some sort of continous integration environment (Cruisecontrol or similar).
Now, how do we go about this? I see that controller code usually does something a la this:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
This doesn't seem viable for plain javacode, since there is no pageContext or web beans in that situation.
Now, I allready tried the most naive approach (tried it in the OAF Tutorial):
EmployeeAMImpl employeeAMImpl = new EmployeeAMImpl();
This of course doesn't work, since none of the VO\EO seem to be instantiated, db connection is probably not set up etc.
The third approach is the one I found in the javadoc for OAApplicationModuleImpl:
// load some basic properties
Properties properties = loadProperties();
javax.naming.Context ic = new InitialContext(properties);
// 'defName' is the JNDI name for the application module
// definition from which the root Application Module is to be created
String defName = "abc.xyz.SampleApplicationModule";
oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
return home.create();
This seems more promising this far, however I need help with the following two questions:
1: Do I really need to go through JNDI to access my AMs from plain javacode (JUnit tests, webservices etc)? If not, how do I then instantiate AMs, complete with EOs, VOs etc?
2: If I do need to go through JNDI: what is the easiest way to register and subsequently call my AMs and their logic\context, particularly for usage from web services and testing frameworks (JUnit etc)?
I'm kinda stumped here, guys. How have you solved this, if you haven't then how would you go about doing it?Hello,
my project is just starting out with the OA Framework. We just encountered our first hurdle - I hope someone here can help out or at least point me in the right direction. None of this stuff seems to be explicitly mentioned in the standard OAF documentation.
This is the situation: We need to call the logic in our Application Modules directly. Two reasons for this:
- We need to expose methods in the AM as web services
- We really want to create unit\integration tests (probably JUnit) and set up some sort of continous integration environment (Cruisecontrol or similar).
Now, how do we go about this? I see that controller code usually does something a la this:
OAApplicationModule am = pageContext.getApplicationModule(webBean);
This doesn't seem viable for plain javacode, since there is no pageContext or web beans in that situation.
Now, I allready tried the most naive approach (tried it in the OAF Tutorial):
EmployeeAMImpl employeeAMImpl = new EmployeeAMImpl();
This of course doesn't work, since none of the VO\EO seem to be instantiated, db connection is probably not set up etc.
The third approach is the one I found in the javadoc for OAApplicationModuleImpl:
// load some basic properties
Properties properties = loadProperties();
javax.naming.Context ic = new InitialContext(properties);
// 'defName' is the JNDI name for the application module
// definition from which the root Application Module is to be created
String defName = "abc.xyz.SampleApplicationModule";
oracle.jbo.ApplicationModuleHome home = ic.lookup(defName);
return home.create();
This seems more promising this far, however I need help with the following two questions:
1: Do I really need to go through JNDI to access my AMs from plain javacode (JUnit tests, webservices etc)? If not, how do I then instantiate AMs, complete with EOs, VOs etc?
2: If I do need to go through JNDI: what is the easiest way to register and subsequently call my AMs and their logic\context, particularly for usage from web services and testing frameworks (JUnit etc)?
I'm kinda stumped here, guys. How have you solved this, if you haven't then how would you go about doing it? -
NoSuchMethodError when call JPublisher method
Im getting a java.lang.NoSuchMethod error when calling a method within
a Java class generated by JPublisher.Hi Larry,
thanks for the answer:
DB Version is:
select * from v$version:
SQL> select * from v$version;
BANNER
Oracle9i Enterprise Edition Release 9.0.1.4.0 - 64bit Production
PL/SQL Release 9.0.1.4.0 - Production
CORE 9.0.1.2.0 Production
TNS for IBM/AIX RISC System/6000: Version 9.0.1.4.0 - Production
NLSRTL Version 9.0.1.4.0 - Production
Is there a possibility to get out if intermedia is installed? I really think it is because the methods work. I can process the image - the problem is that somehow a error occurs but the the method worked. The image written to the filesystem has the correct values.
describe ordsys.ordimage leads to the expected output:
SQL> describe ordsys.ordimage;
Element Type
SOURCE ORDSYS.ORDSOURCE
HEIGHT INTEGER
WIDTH INTEGER
CONTENTLENGTH INTEGER
FILEFORMAT VARCHAR2(4000)
CONTENTFORMAT VARCHAR2(4000)
COMPRESSIONFORMAT VARCHAR2(4000)
MIMETYPE VARCHAR2(4000)
INIT FUNCTION
COPY PROCEDURE
PROCESS PROCEDURE
PROCESSCOPY PROCEDURE
SETPROPERTIES PROCEDURE
CHECKPROPERTIES FUNCTION
GETHEIGHT FUNCTION
GETWIDTH FUNCTION
GETFILEFORMAT FUNCTION
GETCONTENTFORMAT FUNCTION
GETCOMPRESSIONFORMAT FUNCTION
SETLOCAL PROCEDURE
CLEARLOCAL PROCEDURE
ISLOCAL FUNCTION
GETUPDATETIME FUNCTION
SETUPDATETIME PROCEDURE
GETMIMETYPE FUNCTION
SETMIMETYPE PROCEDURE
GETCONTENTLENGTH FUNCTION
GETCONTENT FUNCTION
GETBFILE FUNCTION
DELETECONTENT PROCEDURE
SETSOURCE PROCEDURE
GETSOURCE FUNCTION
GETSOURCETYPE FUNCTION
GETSOURCELOCATION FUNCTION
GETSOURCENAME FUNCTION
IMPORT PROCEDURE
IMPORTFROM PROCEDURE
EXPORT PROCEDURE
PROCESSSOURCECOMMAND FUNCTION
OPENSOURCE FUNCTION
CLOSESOURCE FUNCTION
TRIMSOURCE FUNCTION
READFROMSOURCE PROCEDURE
WRITETOSOURCE PROCEDURE
MIGRATEFROMORDIMGB PROCEDURE
MIGRATEFROMORDIMGF PROCEDURE
GETPROPERTIES PROCEDURE
I do not want to use a database link. everything is stored in that one database. I really have no clue why plsql thinks I want to.
Regards,
Markus -
Which object called the method
Suppose there is a class A which has three objects a1,a2,a3 and a method m. Now I'd like to know which particular object has called the method m.
>
which particular object has called the method
What class called my method
http://developer.java.sun.com/developer/qow/archive/104
a.The advice in the posted link is unreliable as the format of printStackTrace() is not standardized. A more reliable way to find out the calling class is to use SecurityManager.getClassContext() or Throwable.getStackTrace() [in JDK 1.4+].
However, it is not clear whether the original poster wanted to know the calling class or the calling object. In the latter case there is no easy way except for modify the signature of method m to accept the reference to the calling object.
Vlad. -
Is it possible to call a method in a servlet from a java script ?
I need to do a dynamic html page . In the page i select some things and then these things must communicate whit a servlet because the servlet will do some DB querys and update the same webpage.
So is it possible to actually call a method of a servlet from a java script? i want to do something that looks like this page:
http://www.hebdo.net/v5/search/search.asp?rubno=4000&cregion=1011&sid=69DHOTQ30307151
So when u select something in the first list the secodn list automaticly updates.
thank you very muchYou can
1. load all the options when loading the page and
set second selection options when user selected
the first; or
2. reload the page when user select first selection
by 'onChange' event; or
3. using iframe so you only need to reload part of
the page. -
Errors in a Java class when calling other methods
I am giving the code i have given the full class name . and now it is giving the following error :
Cannot reference a non-static method connectDB() in a static context.
I am also giving the code. Please do help me on this. i am a beginner in java.
import java.sql.*;
import java.util.*;
import DButil.*;
public class StudentManager {
/** Creates a new instance of StudentManager */
public StudentManager() {
Connection conn = null;
Statement cs = null;
public Vector getStudent(){
try{
dbutil.connectDB();
String Query = "Select St_Record, St_L_Name, St_F_Name, St_Major, St_Email_Address, St_SSN, Date, St_Company, St_Designation";
cs = conn.createStatement();
java.sql.ResultSet rs = cs.executeQuery(Query);
Vector Studentvector = new Vector();
while(rs.next()){
Studentinfo Student = new Studentinfo();
Student.setSt_Record(rs.getInt("St_Record"));
Student.setSt_L_Name(rs.getString("St_L_Name"));
Student.setSt_F_Name(rs.getString("St_F_Name"));
Student.setSt_Major(rs.getString("St_Major"));
Student.setSt_Email_Address(rs.getString("St_Email_Address"));
Student.setSt_Company(rs.getString("St_Company"));
Student.setSt_Designation(rs.getString("St_Designation"));
Student.setDate(rs.getInt("Date"));
Studentvector.add(Student);
if( cs != null)
cs.close();
if( conn != null && !conn.isClosed())
conn.close();
return Studentvector;
}catch(Exception ignore){
return null;
}finally {
dbutil.closeDB();
import java.sql.*;
import java.util.*;
public class dbutil {
/** Creates a new instance of dbutil */
public dbutil() {
Connection conn;
public void connectDB(){
conn = ConnectionManager.getConnection();
public void closeDB(){
try{
if(conn != null && !conn.isClosed())
conn.close();
}catch(Exception excep){
The main error is occuring at the following lines connectDB() and closeDB() in the class student manager. The class dbutil is in an another package.with an another file called connectionManager which establishes the connection with DB. The dbutil has the openconnection and close connection methods. I have not yet written the insert statements in StudentManager. PLease do Help meYou're doing quite a few things that will cause errors, I'm afraid. I'll see if I can help you.
The error you're asking about is caused by the following line:
dbutil.connectDB();
Now first of all please always ensure that your class names begin with capital letters and your instances of classes with lowercase letters. That's what everybody does, so it makes your code much easier to follow.
So re-write the couple of lines at the beginning of your dbutil class like this:
public class Dbutil {
/** Creates a new instance of Dbutil */
public Dbutil() {
Now you need to create an instance of dbutil before you can call connectDB() like this:
Dbutil dbutil = new Dbutil();
now you can call the method connectDB():
dbutil.connectDB();
The problem was that if you don't create an instance first then java assumes that you are calling a static method, because you don't need an instance of a class to call a static method. If it was static, the method code would have been:
public static void connectDB(){
You have a fine example of a static method call in your code:
ConnectionManager.getConnection();
If it wasn't a static method your code would have to look like this:
ConnectionManager connectionManager = new ConnectionManager();
connectionManager.getConnection();
See the difference? I also know that ConnectionManager.getConnection() is a call to a static method because it begins with a capital letter.
Anyway - now on to other things:
You have got two different Connection objects called conn. One is in StudentManager and the other is in Dbutils, and for the moment they have nothing to do with each other.
You call dbUtil.connectDb() and so if your connectDb method is working properly you have a live connection called conn in your dbUtil object. But the connection called conn in StudentManager is still null.
If your connection in the dbUtil object is working then you could just add a line after the call to connectDb() in StudentManager so that the StudentManager.conn object references the dbUtil.conn object like this:
dbutil.connectDB();
conn = dbUtil.conn; -
How to call java methods from different java file.
Hi, i create 2 files:
CircleCalculationMethod.java
Main.java
In Main.java, How can i call method in CircleCalculationMethod.java ?
Should i put everything in same folder ??
Should i do something like "import CircleCalculationMethod.java"
Should i do something like create a package
Thanks
P/S: i use Eclipse softwareAs I suggested in your OTHER threads - the BEST WAY to learn, and often the fastest, is to TRY THINGS yourself.
Just posting code you get from the internet and asking others to modify it for you won't teach you anything.
Go through The Java Tutorials. There are trails for ALL of the basic functionality that include working, sample code.
This is the trail on 'Packages':
Lesson: Packages (The Java™ Tutorials > Learning the Java Language)
And this is the one on 'Classes and Objects'. This trail includes sections for methods and how to define and use them.
Lesson: Classes and Objects (The Java™ Tutorials > Learning the Java Language) -
Java.rmi.ConnectException on calling callback method
I have an interface exposed as a remote service with a simple method to register the callback object on wich the server calls a method to notify an event.
public void registerForNotification (ExitCodeCallback callback) throws RemoteException;
public interface ExitCodeCallback extends Remote
* @param event
* @throws RemoteException
public void notifyExitCode (ExitCodeEvent event) throws RemoteException;
public class ExitCodeEvent implements Serializable
* Comment for <code>serialVersionUID</code>
private static final long serialVersionUID = -8542839971016423057L;
private Integer code;
private String sourceName;
* @param source
* @param exitCode
public ExitCodeEvent (String source, Integer exitCode)
exitCode = code;
sourceName = source;
* @return Object
public Object asString ()
return sourceName + " exited with code " + code;
}When the server try to call this method causes an exception to be thrown
java.rmi.ConnectException: Connection refused to host: 26.2.242.76; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(RemoteObjectInvocationHandler.java:179)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(RemoteObjectInvocationHandler.java:132)
at $Proxy2.notifyExitCode(Unknown Source)
at it.sogei.jscheduler.rmi.server.SchedulerServicesServerSide$InnerServerExitCodeCallback.notifyExitCode(SchedulerServicesServerSide.java:156)
at it.sogei.jscheduler.rmi.server.ApplicationTask.notifyExitCode(ApplicationTask.java:129)
at it.sogei.jscheduler.rmi.server.WaiterThread.run(WaiterThread.java:47)
at java.lang.Thread.run(Thread.java:595)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:516)
at java.net.Socket.connect(Socket.java:466)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:179)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
... 10 morebut, surprisingly, the client receives the event even if the ExitCodeEvent.asString() called on that object print the following line
null exited with code null.
I wonder how this could be happened?- It happens every single time the callback method is invoked, I see the event been deserialized client-side with the fields initialized with null values and server-side there is the java.rmi.ConnectException.
- The client can't unexport the callback object, that's because I didn't think to do it.
this is the method where I start to notify to all the registered client the event
for (ExitCodeCallback callbackElement : callback)
try
callbackElement.notifyExitCode(event);
catch (RemoteException ex)
logger.debug("Unable to notify.", ex);
}where
List<ExitCodeCallback> callback;and implementation of the callback interface is
public class ClientExitCodeCallback implements ExitCodeCallback
transient Logger logger = Logger.getLogger(ClientExitCodeCallback.class);
* @see it.sogei.jscheduler.ExitCodeCallback#notifyExitCode()
public void notifyExitCode (ExitCodeEvent event) throws RemoteException
logger.warn(event.asString());
} -
Calling arbitrary method with expression language
I'm new to JSP, but have a strong background in Java. I've created a bean that I've included on a JSP page that is meant to manage access to a database. On this bean I have a method
public int createNewRecord();which will create a new record and return its id. I then want to embed this id in a link within my webpage by using something like:
<jsp:useBean id="dbBean" scope="application" class="com.myDomain.DatabaseIfaceBean"/>
<html>
<body>
Link to <a href="relativePage.jsp?recordId=${dbBean.createNewRecord}">record page</a>
</body>
</html>However, this doesn't work. Is there a way to call this method? If this method accepted arguments, is there some way I could pass arguments to it?Its a bit long winded, but EL functions would be the way to go. [url http://www.sitepoint.com/article/java-6-steps-mvc-web-apps/6]Here's a link (search for EL functions in the page)
ram. -
Call a method in VB dll from Java Web Application
Hi,
I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? And, if it is not possible with a tool, can you help me with an example of JNI using?
Thank you
Marymaria_eg wrote:
I'm trying to call a method of a VB dll, from a web application developing with J2EE. Is it possible without JNI? Maybe using Runtime#exec() and rundll32.exe. Depends on the DLL which you want to call.
And, if it is not possible with a tool, can you help me with an example of JNI using?JNI tutorial: http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
JNI forum: http://forum.java.sun.com/forum.jspa?forumID=52 -
How to Call C++ Method from Java
I need to call C++ method from Java.
I have gone through the JNI tuorial , but was not able to pin point things.
I read that :
You have to write JNI c functions which then call your C++ member functions.You need to write a JNI function which will call new on your C++ class.
Now i have java class :
Java Code JavaClass.java ---->
class JavaClass{
public native void nativeMethod();
static
System.loadLibrary("NativeCppCode");
private void callCppMethod()
//call C++ method
JavaClass jvc = new JavaClass();
jvc.nativeMethod()
}Cpp Code:
NativeCppCode.h---->
class NativeCppCode
public:
getValue();
setValue();
private:
int a;
JNIEXPORT void JNICALL Java_JavaClass_nativeMethod(JNIEnv *env
,jobject obj);NativeCppCode.C---->
NativeCppCode::getValue()
return a;
NativeCppCode::setValue()
a = 1;
JNIEXPORT void JNICALL Java_JavaClass_nativeMethod(JNIEnv *env
,jobject obj)
NativeCppCode* nativeInstabce = new NativeCppCode();
NativeCppCode.setValue();
}Is this the correct way to do it.
Any suggestion would be a great help to metryit wrote:
I need to call C++ method from Java.Not possible.
JNI uses C methods.
Is this the correct way to do it.Same way you would do it in any C/C++ method (not java)
MyClass* p = ....
p->doit();
Common idiom for the pointer in the above is to pass it back and forth to your java code as a java long. You cast it it and from your class pointer. Provide an explicit java method to free it when done. Besides providing the explicit method also implement a finalizer to free it as well (however that is a fail safe and should not be relied upon.) -
How to return a object from a method in a java program to a C++ call (JNI )
Sir,
I am new to java and i have been assigned a task to be done using JNI.
My question is,
How can i return an object from a method in a java program to a call for the same method in a C++program using JNI.
Any help or suggesstions in this regard would be very useful.
Thanking you,
Anjan KumarHello
I would like to suggest that JNI should be your last choice and not your first choice. JNI is hard to get right. Since the JNI code is executing in the same address space as the JVM, any problems (on either side) will take down the entire process. It dilutes the Write Once Run Anywhere (WORA) value proposition because you need to provide the JNI component for all hardware/OS platforms. If you can keep your legacy code(or whatever you feel you need to do in JNI) in a separate address space and communicate via some inter-process channel, you end up with a system that is more flexible, portable, and scalable.
Having said all that, head over to the Java Native Interface: Programmer's Guide and Specification web page:
http://java.sun.com/docs/books/jni/
Scroll down to the Download the example code in this book in ZIP or tar.gz formats. links and download the example source. Study and run the example sources. The jniexamples/chap5/MyNewString demo creates a java.lang.String object in native code and returns it to the Java Language program.
Maybe you are looking for
-
How to deal with dwindling space on the server.
Hi everyone,I have to imagine this topic has been discussed at length here, but my Google Fu seems to be rather weak, as I haven't found anything that really addresses this question for me. I'm on month #3 in my first non-hotel IT job and I'm looking
-
Hello, my ipod nano 6th generation is with the black screen, now restored, already pressed for 8 seconds and decrease volume botação start and not resolved, can someone help?
-
Upgraded and lost some fonts--restore?
I created an InDesign File when I had CS2 installed years ago, and since then I've rebuilt my computer and installed CS4. When I opened that old InDesign File, I got lots of missing font warnings. So I take it that a bunch of fonts that came with CS2
-
What is Adobe Flash Player Utility
What is Adobe Flash Player Utility that I see in my Windows 8 Task Manager?? I found a way to disable it by renaming a couple Flash files in the Windows folder. And so far I see no ill effects. Also, when I try to change the Updates in Global Setting
-
Can someone explain the -beyone kernel to me ?
I think it is a normal kernel with added patches to increase compatibility and features but I'm not 100 % sure. Could someone explain this to me in detail ? Thanks.