Thank you a milion for your help ! Best regards ! Tin Huynh
----- Original Message ----- From: "horwat" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 05, 2001 1:01 AM Subject: Re: How could i calulate the string expression ? > You could use Rhino which is an open source implementation of javascript > entirely written in java. All you'd need to do is pass in your expression > string. You'll need to set up a context and scope for javascript but that is > all documented on the website: > > http://www.mozilla.org/rhino > > I'm currently using javascript as an expression language for the JSPTL > project. Here is a snippet of my code as an example of how it's setup: > > ----- > // Creates and enters a Context. Context stores information > // about the execution environment of a script > Context cx = Context.enter(); > // Initialize standard objects > Scriptable scope = cx.initStandardObjects(null); > Object eval = null; > > try { > eval = null; > eval = cx.evaluateString(scope, expression, "", 0, null); // > expression > > // Convert to string (if needed) > // result = cx.toString(eval); > > // Unwrap scoped object > if (eval instanceof Wrapper) > eval = ((Wrapper) eval).unwrap(); > > } catch (JavaScriptException jse) { > throw new JspException(jse.getMessage()); > } > > System.out.println("JAVASCRIPT result: " + eval + ":"); > ----- > > Justy > > ----- Original Message ----- > From: "Huynh Tin" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, October 04, 2001 2:11 AM > Subject: How could i calulate the string expression ? > > > > Hi all ! > > I'm sorry for my basic question. > > Could anybody show me how i can calculate the expression. For example > > if i write directly in sources codes as follow ...it's ok. i can get the > > value of expression. > > double md = (1+2)*3; > > > > But i have a string variable that contain "(1+2)*3"...for example. i do > like > > this > > String msExp = "(1+2)*3"; > > This is my problem . How could i calculte the value of the expression. > > > > Are there any function to do this or any example about this. > > > > Thank you for your helps > > > > Tin Huynh > > > > > =========================================================================== > > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff > JSP-INTEREST". > > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST > DIGEST". > > Some relevant FAQs on JSP/Servlets can be found at: > > > > http://java.sun.com/products/jsp/faq.html > > http://www.esperanto.org.nz/jsp/jspfaq.html > > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets > > > > =========================================================================== > To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". > For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". > Some relevant FAQs on JSP/Servlets can be found at: > > http://java.sun.com/products/jsp/faq.html > http://www.esperanto.org.nz/jsp/jspfaq.html > http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP > http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets > > =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant FAQs on JSP/Servlets can be found at: http://java.sun.com/products/jsp/faq.html http://www.esperanto.org.nz/jsp/jspfaq.html http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
