On Tue, Mar 6, 2012 at 9:50 AM, Afkham Azeez <az...@wso2.com> wrote: > I was also thinking the same. But since this is JavaScript, doesn't the > type conversion automatically happen? Perhaps not. How will it know whether > "1" is a String or int.
That's correct. And I think it's ok too. This is consistent with JSP/Servlet API. If we are to solve this problem I think we should introduce more methods to the API such as getParameterAsInt and getParameterAsDouble. Thanks, Hiranya > > > On Tue, Mar 6, 2012 at 9:33 AM, Nuwan Bandara <nu...@wso2.com> wrote: > >> Hi Samisa, >> >> When you take the parameters from the request they are not type bound. >> they will be always String, and if you are sure that some parameter is an >> Integer you can cast it to a Integer and do math operations on it. >> >> It goes same for Java HTTPServletRequest [1] >> >> [1] >> http://docs.oracle.com/javaee/6/api/javax/servlet/ServletRequest.html#getParameter(java.lang.String) >> >> Regards, >> /Nuwan >> >> On Tue, Mar 6, 2012 at 8:07 AM, Ruchira Wageesha <ruch...@wso2.com>wrote: >> >>> I don't think it is possible to differentiate request parameters as >>> strings, integers, floats etc. i.e. when we pass something as a request >>> param from the client side, we don't consider their types. >>> >>> If I have understand your question properly, what is would be >>> the rationale behind identifying params in [1] as numbers and [2] as >>> strings? >>> >>> Thanks & Regards, >>> Ruchira >>> >>> [1] http://foo.com/calc?param1=1¶m2=2 >>> [2] http://foo.com/search?param1=hello¶m2=world >>> >>> On Mon, Mar 5, 2012 at 8:29 PM, Samisa Abeysinghe <sam...@wso2.com>wrote: >>> >>>> Reason I am saying is that I wrote a cal to demo session and >>>> the param could not be added out of the box. I have to make use of ' * >>>> parseFloat'* >>>> >>>> See code below. >>>> >>>> <% >>>> var operation = request.getParameter("operation"); >>>> var value1 = parseFloat( request.getParameter("value1") ); >>>> var value2 = parseFloat( request.getParameter("value2") ); >>>> >>>> var result = 0; >>>> var memory = 0; >>>> >>>> if (operation == "add" ) { >>>> result = value1 + value2; >>>> } else if (operation == "sub" ) { >>>> result = value1 - value2; >>>> } else if (operation == "mul" ) { >>>> result = value1 * value2; >>>> } else if (operation == "div" ) { >>>> result = value1 / value2; >>>> } else if (operation == "mem" ) { >>>> memory = session.get("result"); >>>> result = memory + value1; >>>> } >>>> >>>> session.put("result", result); >>>> >>>> if (operation == "mem" ) { >>>> print( memory + " + " + value1 + " = " + result ); >>>> } else { >>>> print( value1 + " " + operation + " " + value2 + " = " + result >>>> ); >>>> } >>>> %> >>>> >>>> >>>> >>>> >>>> On Mon, Mar 5, 2012 at 8:27 PM, Samisa Abeysinghe <sam...@wso2.com>wrote: >>>> >>>>> Cannot treat a number param as a number. >>>>> >>>>> Thanks, >>>>> Samisa... >>>>> >>>>> Samisa Abeysinghe >>>>> VP Engineering >>>>> WSO2 Inc. >>>>> http://wso2.com >>>>> http://wso2.org >>>>> >>>>> Thanks, >>>> Samisa... >>>> >>>> Samisa Abeysinghe >>>> VP Engineering >>>> WSO2 Inc. >>>> http://wso2.com >>>> http://wso2.org >>>> >>>> >>>> >>>> _______________________________________________ >>>> Carbon-dev mailing list >>>> Carbon-dev@wso2.org >>>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>>> >>>> >>> >>> >>> -- >>> Ruchira Wageesha >>> Software Engineer - WSO2 Inc. www.wso2.com >>> >>> Email: ruch...@wso2.com Blog: ruchirawagee...@blogspot.com >>> Mobile: +94775493444 >>> >>> Lean . Enterprise . Middleware >>> >>> _______________________________________________ >>> Carbon-dev mailing list >>> Carbon-dev@wso2.org >>> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >>> >>> >> >> >> -- >> *Thanks & Regards, >> >> Nuwan Bandara >> Senior Software Engineer >> WSO2 Inc. | http://wso2.com >> lean . enterprise . middleware >> >> http://nuwan.bandara.co >> * >> <http://www.nuwanbando.com/> >> >> _______________________________________________ >> Carbon-dev mailing list >> Carbon-dev@wso2.org >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >> >> > > > -- > *Afkham Azeez* > Director of Architecture; WSO2, Inc.; http://wso2.com > Member; Apache Software Foundation; http://www.apache.org/ > * <http://www.apache.org/>** > email: **az...@wso2.com* <az...@wso2.com>* cell: +94 77 3320919 > blog: **http://blog.afkham.org* <http://blog.afkham.org>* > twitter: **http://twitter.com/afkham_azeez*<http://twitter.com/afkham_azeez> > * > linked-in: **http://lk.linkedin.com/in/afkhamazeez* > > * > * > *Lean . Enterprise . Middleware* > > > _______________________________________________ > Carbon-dev mailing list > Carbon-dev@wso2.org > http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev > > -- Hiranya Jayathilaka Associate Technical Lead; WSO2 Inc.; http://wso2.org E-mail: hira...@wso2.com; Mobile: +94 77 633 3491 Blog: http://techfeast-hiranya.blogspot.com
_______________________________________________ Carbon-dev mailing list Carbon-dev@wso2.org http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev