java matlab函数 mwnumericarray,jsp 调用matlab函数

有没有做好的demo啊,发一份到我邮箱,让我学习学习》

我的例子也是通过调servlet来实现。但是构建对像的时候就报错,好像是不能构建的样子。

请大家帮我看看。

我通过jsp调用servlet.

// imported classes from JRE

import java.io.IOException;

// imported classes from servlet-api.jar

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import javax.servlet.http.HttpSession;

import javax.servlet.ServletException;

import javax.servlet.ServletConfig;

import javax.servlet.ServletContext;

import javax.servlet.RequestDispatcher;

// imported classes from javabuilder.jar

import com.mathworks.toolbox.javabuilder.*;

import com.mathworks.toolbox.javabuilder.web.MWHttpSessionBinder;

import com.mathworks.toolbox.javabuilder.webfigures.WebFigure;

//import com.mathworks.toolbox.javabuilder.webfigures.WebFigure;

//import com.mathworks.toolbox.javabuilder.MWJavaObjectRef;

//import com.mathworks.toolbox.javabuilder.MWException;

//import com.mathworks.toolbox.javabuilder.MWArray;

//import com.mathworks.toolbox.javabuilder.web.MWHttpSessionBinder;

// imported classes from plot.jar

import com.mathworks.examples.plot.*;

import com.mathworks.examples.magicsquare.*;

public class ModelRunnerServlet extends HttpServlet

{

MWNumericArray n = null;   /* Stores input value */

Object[] result = null;    /* Stores the result */

private  magic theMagic = null;     /* Stores magic class instance */

//private plot matlabModel = null;

public void init(ServletConfig config) throws ServletException

{

super.init(config);

try {

// create a new plotter object

theMagic=new magic();//经检测,到这里就报那个错。我列出来那个错。什么原因呢?我在java类里面直接调用是可以实现的。

//matlabModel = new plot();

}

//MWException mcrInitError

catch (Exception mcrInitError) {

mcrInitError.printStackTrace();

}

}

public void destroy()

{

super.destroy();

// free MCR-related resources

//matlabModel.dispose();

}

protected void doGet(final HttpServletRequest request, HttpServletResponse response)

throws ServletException, IOException

{

/*

HttpSession session = request.getSession();

ServletContext servletContext = session.getServletContext();

// find the plotter object associated with this session

WebFigure userPlot = (WebFigure)session.getAttribute("UserPlot");

// if this is the first time doGet has been called for this session,

//  create the plot and WebFigure object

if (null == userPlot) {

try {

// generate the plot /* nargout = */

//Object[] results = matlabModel.getplot( 1);

//try {

// unpack the WebFigure

//MWJavaObjectRef ref = (MWJavaObjectRef)results[0];

// userPlot = (WebFigure)ref.get();

// store the figure in the session context

//session.setAttribute("UserPlot", userPlot);

// bind the figure's lifetime to the session

//session.setAttribute("UserPlotBinder",

//   new MWHttpSessionBinder(userPlot));

//}

//finally {

// free MCR-related resources held by the results

// MWArray.disposeArray(results);

//}

// }

//catch (MWException getplotError) {

//getplotError.printStackTrace();

//}

//}

// forward the request to the View layer (response.jsp)

RequestDispatcher dispatcher = request.getRequestDispatcher("/response.jsp");

dispatcher.forward(request, response);

}

}

[本帖最后由 javasu 于 2009-8-6 09:20 编辑]

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值