Juggle between jstl and jsp!

I have a list of items and whose size is obtained by jstl as follows:
<c:set var="num" value="${fn:length(form.namesList)}"/>I have to find the number of blocks using jsp and I am trying as follows which is giving jspException.
<%int numCols = (int)Math.ceil( num / 10.0);%>Can anyone tell me the problem over here?
I need to use numCols to display my results using jstl as follows:
<c:forEach var="y" begin="${1}" end="${numCols }">
</c:forEach>Can juggle between jstl and jsp like this?

This depends on the version of JSP you are using:
If you are using JSP 2.0 (like Tomcat 5), make sure you have downloaded and installed JSTL 1.1 and set the web.xml up to use the Servlet 2.4 specs. Then the code you wrote should work.
If you are using JSP 1.x (like Tomcat 4 and below), make sure you have JSTL 1.0. Then you can only use EL (the Expression Language used to translate ${...} expressions) inside JSTL.
If you want to use EL inside your custome tags, look through the Apache Jakarta sight. Somewhere they have an ELExpression translator (a couple of classes actually - whose full names I forget). These classes will let you take the ${...} expressions in as strings, pass them through the translators and get the correct objects back out.
Or you could go a simpler root:
<mob:whatever object="test" name="newname" />
then in your custom tag:
  MyType test = (MyType)pageContext.findAttribute(object);
  test.setName(name);

Similar Messages

  • Switching between Design and JSP tabs add code?

    I am new to SJSC and I am taking the time to go through all of the little odds & ends of the IDE.
    I was looking at:
    http://blogs.sun.com/roller/page/tor?entry=computing_html_on_the_fly
    And I decided to try this.
    When I add the following in the JSP tab:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>Save.
    Then click on the Design tab, then go back to the JSP tab, I now have:
    <h:outputText binding="#{Page1.tableHtml}" id="outputText1"/>
    <h:outputText binding="#{Page1.outputText1}" id="outputText1"/>It's late here, but this doesn't make any sense, why would switching between Design and JSP tabs add code?
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Girish: I followed these steps:
    1.) Downloaded:
    Sun Java Studio Creator 2, Multilanguage creator-2-windows-ml.exe 254.23 MB
    2.) When I started the install, I received the message:
    Welcome to Sun Java(TM) Studio Creator 2! You are installing: Sun Java Studio Creator 2 development environment Sun Java System Application Server Platform Edition 8.1 2005Q1 Update Release 2 Bundled database
    3.) Installed version:
    Product Version: Java Studio Creator 2 (Build 060120)
    IDE Versioning: IDE/1 spec=5.9.1.1 impl=060120
    Also, Under, the Palette window: Standard component list, there is a component labeled Output Text.
    When placed on a jsp, the following code is produced:
    <h:outputText binding="#{Page1.outputText1}" id="outputText1" style="position: absolute; left: 24px; top: 48px"/>Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Difference between JSTL and JSF

    Hi
    I am little bit confuse between JSTL and JSF. can one tell me what is difference between JSTL and JSF ?
    Thanks & regards,
    Ben

    from suns site
    The JavaServer Pages Standard Tag Library (JSTL) encapsulates as simple tags the core functionality common to many Web applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization tags, and SQL tags.
    http://java.sun.com/javaee/javaserverfaces/overview.html

  • Can objects be passed between Applets and JSP?

    Can objects be passed between Applets and JSP? If so how? Thanks in advance.
    Scott

    see if this helps,
    http://forum.java.sun.com/thread.jsp?forum=54&thread=136847

  • Propagation of ctx between EJB and JSP

    Hello,
    Does anybody know how to propagate the Security
    Context between EJB and JSP so that when I login in my JSP page the user will be after recognized in my EJB system ?
    Thanks
    Francesco

    try this...as a test..
    take a simple Contact ejb (as simple as you can make it, just a name and email address). In the ejb-jar.xml set up a role, for example, user, and restrict the access to only this role for all methods.
    try to access the ejb from a jsp, and you should get the login form identified in your web.xml file.
    make sure that the ejb is noted in the web.xml file, also.
    this should work...
    no try this...identify a role in your web.xml file, (user, for example) and restrict the access to the a particular jsp which is not calling the ejb. IF you navigate to this jsp, you should get the login prompt...
    this should work....
    now the tough part
    in your application.xml create a role with the same name, user. By doing this, you have created a global role, and connect the two together.
    Now point your browser to the restricted jsp with no calls to the ejb...you should get the login, so login in.
    now navigate to your jsp which is unrestricted, but calls the restricted ejb...
    there should now be no login prompt.
    This should work.

  • Difference between facelets and jsp xml in Document Type

    I want difference between facelets and jsp in Document Type in JDeveloper 11gR2 (11.1.2)
    Thanks
    Edited by: Amr Ahmed on Jun 8, 2011 7:46 AM

    Let's see.
    Facelets creates a facelets page
    JSP creates a JSP page
    {noformat}:){noformat}
    Facelets is the "official" view language for JSF 2.0
    http://www.realdevelopers.com/blog/development/facelets-vs-jsp should give you some more insight as well.
    John

  • Differnce between jstl and struts

    hi friends
    Can anyone one tell me the difference between struts and jstl.
    Let me know which one is most suitable to use.
    thanks in advance

    Is google not installed on your machine?
    Struts and JSF are both web application development frameworks. Both have advantages/disadvantages. Google around for comparisions. There are many around the internet.
    JSTL is a library of useful custom tags for JSP. It enables you to avoid using scriptlet code in JSPs.
    Struts and JSTL are not mutually exclusive. In fact they work quite well together.
    JSF and JSTL don't play so well together. That may have changed with the JSP2.1 unified expression language, but if you're writing JSF, you normally don't need JSTL tags.
    Cheers,
    evnafets

  • What is different between strut and jsp+servlet+javabean?

    welcome

    Struts is a package that sits on top of the usual webapp stuff and organises and makes regular a lot of the stuff you wind up doing in servlets without it.
    It handles stuff like the objects you usually wind up using to pass data between JSPs and forms and servlets.
    It implements transaction stearing rules.

  • Difference between JSTL and struts

    Hi all...
    I am using struts in project. Some of them using JSTL for create JSP. Wat is advantage of JSTL over STRUTS.
    Is any Extra Functinalities available in JSTL over struts?

    hi,
    yes JSTL has some advantages over Struts tags.
    JSTL tags really help you write 0 scriptlet code.
    Also, the JSTL tags are more readable and easy to understand.
    e.g. <c:if> is much simpler than <logic:equal>
    In fact logic:equla just allow you to compare for equality/inequality. Whereas in c:if you can specify
    any condition just as in any backend language.
    It also facilitates many mathematical operations.
    e.g. consider example, where you want are dispalying list (html table) and you want to use alternate CSS for even and odd row. How can you do it with strutsWITHOUT using scriptlets.
    but with JSTL you can do so,:
    Put the following code inside <logic:iterate> or i'll suggest <c:forEach> tag..:))
    <c:if test="${rowIndex%2 == 0}">
                    <c:set var="cssClass" value="datacelltwo"/>
               </c:if>
               <c:if test="${rowIndex%2 != 0}">
                    <c:set var="cssClass" value="datacellone"/>
               </c:if>
               <c:set var="rowIndex" value="${rowIndex+1}"/>

  • Passing a variable between html and jsp

    Hello there,
    I'm writing a simple application to show the use of custom tags. I have an html page with a dropdown box. Based on the selection from the dropdown box what the jsp outputs will be different. Can anyone tell me how to use the variable from the html page in the jsp page? The code is as follows:
    manager.html <form method="post" action="manager.jsp">
              <body>
                   <form>
                        <select name="person">
                        <option value="pevans">PEVANS
                        <option value="mgleeson">MGLEESON
                        <option value="jmolony">JMOLONY
                        <option value="pmccarthy">PMCCARTHY
                        <option value="jwalsh">JWALSH
                        </select>
                        <input type="submit" value="Submit" />
                   </form>
              </body>
    </form>and manager.jsp
    <%@ taglib prefix="man" uri="/tags/weekdayTags"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
    <table border="1">
         <man:forEachLine manager="html selection" var="line">
              <tr>
                   <c:forTokens items="${line}" delims="," var="field">
                        <td><c:out value="${field}"/></td>
                   </c:forTokens>
              </tr>
         </man:forEachLine>
    </table>Thanks very much,
    Ger

    You need to use the response.getParameter("selectName") method which will return a String with the selected value.

  • Pass Object Between Applet and JSP Page

    Hi all,
    How can I pass an Object(such as Vector, File), rather than just string to the Applet from a JSP page?
    Thank you.

    I used Base64Encoder and Base64Decoder from servlets.com utilities.
    * convert any serializable object to a String
    public synchronized static String objectToString(Serializable obj) throws Exception {
        ByteArrayOutputStream bos = new ByteArrayOutputStream(100);
        ObjectOutputStream oos = new ObjectOutputStream(bos);
        oos.writeObject(obj);
        byte[]bytes = bos.toByteArray();
        bos = new ByteArrayOutputStream(); //to save the encoded String
        Base64Encoder enc = new Base64Encoder(bos);
        enc.write(bytes);
        String encodedString = bos.toString();
        //close all
        enc.close();   
        oos.close();
        bos.close();
        return encodedString;
    * Recreates the object from the encoded String
    public synchronized static Object stringToObject(String str) throws Exception {
        ByteArrayInputStream bis = new ByteArrayInputStream(str.getBytes());
        Base64Decoder dec = new Base64Decoder(bis);
        ObjectInputStream ois = new ObjectInputStream(dec);
        Object obj = (Object)ois.readObject();
        ois.close();
        dec.close();
        bis.close();
        return obj;
    }

  • How to communicate between Flex and JSP and show the result in an Iframe

    Hi all
    I am trying to send some data from flex to one HTTPService and trying to show the same response jsp in an Iframe. But unfortunately i am unable to get the responce Jsp's url to set as a source for iframe.
    let me explain you clearly...I have a mxml where i am having a text box and a button in the left panel and in the right panel i am having an Iframe to display jsp. So once user enters some value in the text box and clicks button then HTTPservice's send method will be called with text box's content as an arguement. So i can fetch that value from request object in jsp and display the value in jsp. So the problem here is i want display that result jsp in my Iframe. I know that , we need that result jsp URL to display in Iframe . But as i am sending POST request to HTTPservice, i am not able to get the result jsp's URL in flex side.
    So i need help desperately from great minds.So anyone of you can give me some suggestions!!!!
    Regards

    Hi all can some one please give a solution ...Any suggestions would be greatly appreciated

  • Passing objects between Servlets and JSP

    Hi,
    I have passed a ResultSet from a Servlet to JSP using RequestDispatcher forward(). I can access the ResultSet in the JSP page. How can I now pass this ResultSet into another JSP page once the form has been submitted?
    Thanks in advance.

    You should never passing expensive resources like ResultSet around like that. This indicate an open DB connection somewhere while it should already be closed at this stage.
    Read on about the DAO pattern and make use of servlets and beans.

  • What is different between asp and jsp, which is better and why

    hi, i would like to know which script language is better (ASP or JSP). if you can give me a detail comparison. Thank in advance
    zhe

    What do you expect small-time loser?

  • How to pass values between applet and jsp

    I have a jsp calling an applet which needs to return value to the calling jsp based on the action. Once the applet returns value to the calling jsp, I need to put that value into the session so that I can use it for the other pages. Could anyone have suggestion how to do it. I am new to applet development. Appreciate your help.

    Why does it have to send the value back via the same JSP? Why not create a servlet to take input from the applet?

Maybe you are looking for

  • How to capture the selected values of the filter?

    Hi Everybody I have created a dashboard using a 4 column filter. It all works well - no problem. I now need to enhance the functionality of the dashboard which needs the selected values of each of the parameters of the filter. As far as I know, the s

  • Best Practice for Production environment

    Hello everyone, can someone share the best practice for a production environment? or is there a SAP standard best practice to follow in a Production landscape? i understand there are Best practices available for Implementation , Migration and upgrade

  • Blue screen of death if I have photos on my iphone 3gs!

    Hi all, Need a little help. If I have photos on my camera roll and I plug the iphone into my laptop I get the BSOD. If I then delete the photos off the iphone and plug into my laptop all is fine. I only get a problem when I have photos on the iphone.

  • How I detect mouse wheel movement?

    I never use this for now, and I want to intercept mouse wheel movement (up or down) for to change animation panels (divs) or to make another actions. Is not for a scroll of a large stage or div, it's only for to know when the user use the mouse wheel

  • Fixed exchange rate in PO vs the exchange rate maintained in OB08

    Dear experts, When I input a PO in ME21N, I noticed that there is a field letting me to input exchange rate. And I also know that the exchange rate the system automatically picks is from what we have maintained in OB08. Can I understand that if we ha