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 <[email protected]> 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 <[email protected]> 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 <[email protected]>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 >> [email protected] >> http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev >> >> > > > -- > Ruchira Wageesha > Software Engineer - WSO2 Inc. www.wso2.com > > Email: [email protected] Blog: [email protected] > Mobile: +94775493444 > > Lean . Enterprise . Middleware > > _______________________________________________ > Carbon-dev mailing list > [email protected] > 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 [email protected] http://mail.wso2.org/cgi-bin/mailman/listinfo/carbon-dev
