Rounding an expression in JSP
Expression.......<TD>\${5 div 6}</TD> in a JSP results in output........0.83333333334.....
I want to round off that value to......0.833...
Please tell me how this can be done.
Thanks BalusC
But can this be done without importing fmp tld.....
is there any function in jstl tld only <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
like Integer.round...i remember of using it sometime back.......
or any other possible way without importing any external tld
Similar Messages
-
Hello Techies,
I am having a text area inside a jsp file. When ever the end user gives input it must be submitted to the server.
The real problem is when the end user gives special characters and double-quotes in this text area, jsp is preforming in abnormal way.
Can u guys tell me how to resolve this issue. i.e how to solve regular expressions in jsp.
Even though the end user gives special characters or double quotes we should take only the content.
Looking forward for u reply.
regards,
RamuThe real problem is when the end user gives special characters and double-quotes in this text area, jsp is preforming in abnormal way.What do you mean with "jsp is preforming in abnormal way" ?
A arbitrary JSP does not care about double-quotes.
Can u guys tell me how to resolve this issue. i.e how to solve regular expressions in jsp.Usually the same way as you do it in a poj class.
Nobody here knows how your JSP looks like and who handles the request when the form is submited or even who generates the model of the data displayed by your JSP.
You have to provide us with more details. -
Hi all codemaster sifu,
Can help in guiding me on rounding up the value key in by user in my JSP website?
The rules:
User type in USDxx.x1 - xx.x2 will become USDxx.x0
User type in USDxx.x3 - xx.x4 will become USDxx.x5
Eg:
USD10.11 -> USD10.10
USD10.12 -> USD10.10
USD10.13 -> USD10.15
USD10.14 -> USD10.15
USD10.16 -> USD10.15
USD10.17 -> USD10.15
USD10.18 -> USD10.20
USD10.19 -> USD10.20
Please help me in doin this in JSP...
Give me some hint/suggesion as I am new, really new to JSP...>_<"
Thanks you so muchtwowordsuckit wrote:
No expert willing to help me on this?There are lots of experts here. Most are not willing to help someone that refuses to do a simple Google search on such a simple problem. Some might not respond because of your username. But I will give you some advice: Don't round numbers in a JSP. -
Does Weblogic Express support JSPs
Does Weblogic Express support JSPs?
Yep!!
Kumar
Bryan Boyer wrote:
>
> Does Weblogic Express support JSPs?
-
Creating an expression from JSP using a non-bound variable
Hi,
This should be a simple question. I have an attribute that belongs to a row that is displayed on a jsp page.
This attribute, however, is not displayed on the page, but is an attribute in the VO.
I have a Set Property Listener on a command button, and I am trying to set this attribute ("Uid") to a pageFlowScope variable.
I am having trouble figuring out which expression to use in order to get the value of my attribute.
I can do this in code:
int i = (Integer)currentRow.getAttribute("Uid");
I want to be able to do the same thing in my expression language.
Can anyone give me a clue?
Or, is there a way I can instantiate a Set Property Listener in my code, and use the value of my attribute?
The attribute I am using is my Auto-Increment primary key (I'm using MySQL), so I never use it as a UI element.
Thanks.
Joel
Edited by: JRolls on Oct 1, 2010 10:30 AMI ended up removing the SetPropertyListener, and then from my backing bean I set the value on my pageFlowScope by doing this:
RequestContext.getCurrentInstance().getPageFlowScope().put("pid", i); -
WL vs. WL-express and JSP vs. javascript/SQL
folks-
i am trying to convince a certain party to
disband a web-based job tracking system being
written in ASP, javascript, html, css and SQL.
it will be hosted on MS webserver running NT.
i am trying to convince them to use JSP and
WL express. i have done two years of EJB
component work on weblogic, however, i have not
done work with JSP or thin-clients. i was mostly
business-logic.
anyway i have some questions and need some
direction. i already know JSP is better than
ASP/javascript etc. because:
* ASP is proprietary. ditto for VBscript
* with an IDE creating JSP is easy and JSP
automatically creates servlets which is way
faster than by hand
* JSP is JAVA based and hence benefits from
all the portability pluses of JAVA
but here are the more difficult questions:
* why is WL express better than an MS
web server? (not including WL market share
and size. after all MS can claim that)
* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding?* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
Use JDO or an OR-mapper or embed JDBC into your own data access classes.
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
Presentation=JSP
Logic=Servlet
Data access=JDO or similar
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
You should be able to tell up front if it a tx-intensive app that requires
WLS.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
They aren't exclusive. For dynamic pages, use Javascript on the front end,
JSP on the back.
* with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding?
In the real world, and for most apps, while Java has the architectural edge,
they both have similar scalability and similar robustness. MS gives you no
choice though, and you rewrite every time they see a new buzzword. You can't
leave MS-land without abandoning almost everything. You can leave WLS in a
week if you have to.
It's an investment. Invest wisely.
Peace,
Cameron Purdy
Tangosol, Inc.
Clustering Weblogic? You're either using Coherence, or you should be!
Download a Tangosol Coherence eval today at http://www.tangosol.com/
"shane miller" <[email protected]> wrote in message
news:[email protected]...
folks-
i am trying to convince a certain party to
disband a web-based job tracking system being
written in ASP, javascript, html, css and SQL.
it will be hosted on MS webserver running NT.
i am trying to convince them to use JSP and
WL express. i have done two years of EJB
component work on weblogic, however, i have not
done work with JSP or thin-clients. i was mostly
business-logic.
anyway i have some questions and need some
direction. i already know JSP is better than
ASP/javascript etc. because:
* ASP is proprietary. ditto for VBscript
* with an IDE creating JSP is easy and JSP
automatically creates servlets which is way
faster than by hand
* JSP is JAVA based and hence benefits from
all the portability pluses of JAVA
but here are the more difficult questions:
* why is WL express better than an MS
web server? (not including WL market share
and size. after all MS can claim that)
* since WL express does not have an EJB
container, how do you access the database?
via JDBC? does one just have JDBC code
floating around?
* since there is no EJB container how does
one separate presentation from logic from
data access? this is a major downside of
javascript, html, css and SQL etc.
* if a web app grows beyond JSP with WL express
into the need for an EJB container, i would
think that most of the app needs to re-written
as business-logic must be refactored into EJBs
and all JDBC code will be replaced by container
managed beans. this sounds a like a lot of
rework.
* isn't JSP slower than javascript as the
servlet and hmtl code is bounced back and
force across the network?
with respect to architecture, scalability,
and robustness what are the downsides to an
MS webserver and non-JSP coding? -
Using ${something} expressions in jsp
hello,
i'm writing a small web application using struts, hibernate, tomcat, my problem is that expressions ${some_formbean_property} written in jsp stay in html code to, they should be replaced with value of the property, what i have to do to fix it??
thanks a lotIn a JSP2.0 container, ${expr} is a runtime expression.
if you use tomcat 5, and declare your web.xml as version 2.4, you can use ${expr} anywhere that you can use <%= expr %>
So you can use it anywhere in template text, and also as an attribute to any tag that takes a runtime expression. -
EL or RT expressions for JSP taglibs
I have a simple question
We all know that there are two ways to implement a JSP page. either RT expressions or expression language (EL). I have done plenty of research and I am comfortable at creating custom JSP taglibs that support both RT and EL. What I want to know is which if them is used more commonly?
Its useless to right 2 seperated libs, since you can pass variables from EL to RT and vice versa, so I want to have only one tag library, but I dont know how I should implement it EL or RT.
What is used more often and why? What is the advantages of using one over the other. Thank you!!!RT was the original way; it required scriptlets, which everyone hates.
EL is the new way; it helps eliminate scriptlets, which everyone loves.
EL is the method of choice; even moreso when JSP 2.0 is finalized, it allows them to be used more freely (not just in tags) -
Expression langage & jsp ?
hi,
in the j2EE tutorial, in the chapter related to Expression langage (EL), we can read "EL Expressions
can be used in two situations, In template text,
In any standard or custom tag attribute that can
accept an expression"
ok have a look at this code
<html>
<c:out value="${1.2E4 + 1.4}"/>
${1.2E10 + 1.4}
</html>the output is
12001.4
${1.2E10 + 1.4} why the second EL ${1.2E10 + 1.4} is not evaluated, even if it appears in the template texte!!!!
perhaps i didn't understand what is a 'template texte' ??
PS : i am using WSAD 5.1 with the built-in WASv5
tahnks for your helphi,
in the j2EE tutorial, in the chapter related to
Expression langage (EL), we can read "EL Expressions
can be used in two situations, In template text,
In any standard or custom tag attribute that can
accept an expression"
ok have a look at this code
<html>
<c:out value="${1.2E4 + 1.4}"/>
${1.2E10 + 1.4}
</html>the output is
12001.4
${1.2E10 + 1.4} why the second EL ${1.2E10 + 1.4} is not evaluated,
even if it appears in the template texte!!!!
perhaps i didn't understand what is a 'template texte'
PS : i am using WSAD 5.1 with the built-in WASv5
tahnks for your help Because the "native" implementation of EL is not available untill JSP 2.0 and was 5 is JSP 1.2.
Thats why - J -
PHP regular expression to JSP?
Hi there,
I have the following PHP regular expression, and was looking for tips on how to create an equivalent in JSP using the 1.3.1 API. This has been causing me problems since the regex package didn't arrive until 1.4.
preg_match("/^(([\w\-\_])+(\.)*)+\@([\w\-\_]+\.)+[A-Za-z]{2,}$/i", $theAddress)Basically, it checks to make sure a valid email address pattern has been input.
Any help would be appreciated!
Thanks!Though I donno about PHP and the related stuff that you've posted, I can help you by providing a JS function that you can invoke to check for the valid format of an e-mail ID, I guess if this is what you want.
function isEmail (s)
// there must be >= 1 character before @, so we
// start looking at character position 1
// (i.e. second character)
var i = 1;
var sLength = s.length;
// look for @
while ((i < sLength) && (s.charAt(i) != "@"))
{ i++
if ((i >= sLength) || (s.charAt(i) != "@")) return false;
else i += 2;
// look for .
while ((i < sLength) && (s.charAt(i) != "."))
{ i++
// there must be at least one character after the .
if ((i >= sLength - 1) || (s.charAt(i) != ".")) return false;
else return true;
}'s' is the e-mail ID string that you want to check.
Hope you're assisted.
fun_one -
Does Weblogic Express support JSP ?
Hi
I wanted to know if i can deploy JSPs if i use a WeblogicExpress instead
of a Weblogic Server .Iam not able to understand the deifference between
Weblogic Express and Weblogic Server inspite of reading the material on the
web site .Can someone throw more light on this ? Is there anywhere i can
compare the features of the different weblogic products at one place ?
thanks
SrinivasFor this type of stuff you should talk to your sales-person.
We just make it, not sell it, so we dont understand the difference
either. :)
Cheers
Mark G.
In article <[email protected]>, [email protected] says...
Hi
I wanted to know if i can deploy JSPs if i use a WeblogicExpress instead
of a Weblogic Server .Iam not able to understand the deifference between
Weblogic Express and Weblogic Server inspite of reading the material on the
web site .Can someone throw more light on this ? Is there anywhere i can
compare the features of the different weblogic products at one place ?
thanks
Srinivas
==================================================
NewsGroup Rant
==================================================
Rant 1.
The less info you provide about your problem means
the less we can help you. Try to look at the
problem from an external perspective and provide
all the data necessary to put your problem in
perspective. -
Deferred expressions inside JSP tags
Hello!
I want to include custom JSP 2.0 tag into page.
Something like
<!-- Page.jsp -->
<jsp:root version="2.0"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:jsp="http://java.sun.com/JSP/Page"
xmlns:pk="urn:jsptagdir:/WEB-INF/tags">
<jsp:directive.page language="java"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" />
<f:view>
<pk:custTag bean="${beanInstance}"/>
</f:view>
</jsp:root>inside that tag I want to access my bean in JSF 1.2 way:
<!-- custTag.tag -->
<jsp:root version="2.0" xmlns:h="http://java.sun.com/jsf/html">
<jsp:directive.tag body-content="empty" language="java"
pageEncoding="ISO-8859-1" />
<jsp:directive.attribute name="bean" required="true" type="com.my.Bean"/>
Runtime way:
${bean}
${bean.prop}
Deferred way:
<h:outputText value="#{bean}"/>
<h:inputText value="#{bean.prop}"/>
</jsp:root>So ${} renders as expected, but <h:outputText> renders nothing as #{} evaluates to null. What should I do to make outputText and inputText work, if that's possible at all?
I use Tomcat 6.0.2 and JSF-RI 1.2_03.
Thanks,
AlexeyOh, I see now.
But is there a way to trick JSF by explicitly putting bean into request scope? Something, like Tomahawk's aliasBean?
Actually, I did try to implement it. The following code was supposed to create a variable in EL-context:
ValueExpression expr = _value instanceof ValueExpression
? (ValueExpression)_value
: facesContext.getApplication().getExpressionFactory().createValueExpression(_value, Object.class);
ELContext ctxt = facesContext.getELContext();
VariableMapper varMap = ctxt.getVariableMapper();
if ( varMap == null ) {
((ELContextImpl)ctxt).setVariableMapper( new VariableMapperImpl() );
varMap = ctxt.getVariableMapper();
if ( varMap != null ) {
varMap.setVariable(_alias, expr);
_active = true;
log.fine("makeAlias: " + _alias + " = " + expr.getExpressionString());
} else {
log.warning("makeAlias: " + _alias + " = " + expr.getExpressionString() + " failed");
}But resolving #{...} still returned null. -
have got some basic doubtd in IDM
We have XML and JSPs how both r getting related in
the sense Take Login Form --> Login.jsp how both
are gettign related
Suppose In form1 I am entering some data that data
if I want to recieve in form 2 How to specify the
action ?
It seems elementary
Thanks in Advance
senthilRajanI'm not really sure I understand your question.
Although it's probably generally true that a JSP file maps to an XML form, it's not always the case.
Can you be more specific about what you are trying to do? Are form1 and form2 different forms that would be presented during the processing of a workflow? Are you referring to end user vs. and admin activity?
Often it can be easier to use a single form that nests fields within fields that can be conditionally disabled. Thus, a single form can look like multiple different forms. Or you can use tabs in the form spread fields out on multiple tabbed pages.
Hope that helps,
sbr -
JSP 1.2: jsp expression in attribute value doesn't parse.
Hi, I'm trying to use a jsp:expression in an html attribute value in JSP 1.2 but jasper doesn't seem to be able to parse it correctly. I'm using the XML syntax in my jsp, the relevant snippets are as follows:
<jsp:scriptlet>
String versionedPath = "/mysite/2.1/images";
</jsp:scriptlet>
<img src="%= versionedPath %/foo.jpg" />
The JSP documentation claims that this will work but I'm beginning to think this syntax won't work when using JSP's XML syntax. I already know that the following won't work:
<img src="<jsp:expression> versionedPath </jsp:expression>/foo.jpg" />
as it did in JSP 1.1 because it's not well-formed xml.
Is it even possible to use jsp expressions in attribute values when using JSP 1.2's XML syntax? If so, please enlighten me, and if not, well, that seems pretty broken to me.
TIA...
--Stuartyou should use this:
<img src=<%= versionedPath %>/foo.jpg > -
Hi,
I would like to know how to round up number in jsp whether it is below 0.5 or above 0.5... my sample code:
double totalquantity=0;
int totalratio = 0;
long q = 0;
ratio = rs.getString("ratio");
q = totalquantity/totalratio * Integer.parseInt(ratio);
thank youyou are getting the double through the expression mentioned
q = totalquantity/totalratio * Integer.parseInt(ratio);
and assigning that to long, without casting.
Hence the problem-Loss Of Precision.Make the q as double,use Math.round() on that depending on u r requirement.
Maybe you are looking for
-
IPhone Battery????
Hi. My IPhone is a 3G (I think) Model MB702LL. It was updated to version 4.2.1. Two days ago started to sign low battery but it seems it doesn't hold a charge.Though my battery level it's totally red I can still make/receive calls. I went to an Apple
-
I am trying to import original cd to my itunes library, and a problem occured. The fact is songs are not imported to the library and a very long numbrer appears in the column for the duration of song. I have over 400 hundred imports before and this p
-
What safari is compatable with 10.3.9?
I lost my Safari and was wondering what safari is compatable with 10.3.9? and where can i find the download?
-
Sender Agreement Endpoint Creation
Hi, I have a SOAP - PI - Proxy scenario where I want to call the sender agreement to initiate the message. In the Integration Builder, I see that I can display the WSDL for the Sender Agreement. If I take that URL and put it into WS Navigator, I ca
-
Computer Not connected to internet...even though it is
hello, i was looking around on the website for help but could'nt find anything about a problem simliar to mine yet. Anyways here's my problem, when i plop in the CD to install my WRT54G, it gets to the 1st step where it verifys the modem for my inter