How can I do sth like this ${requestScope.list.size} ?

Hi, I have 2 attributes which I pass like this
requsest.setAttribute("startPoint", 3);
request.setAttribute("myList", myList);
where myList is a ArrayList filld with objects. On jsp page I want to count 2 values first and last number:
<c:set var="firstNumber" value="${requestScope.startPoint+1}"/> - this works fine.
<c:set var="lastNumber" value="${requestScope.startPoint+requestScope.myList.size}"/> - this is impropper.
How can I use as integer size of list which is passed as request attribute. Is this possible?
I would appreciate any hepl.

Hang on. For such things you can build your own EL functions - it is very easy and involves only 4 steps.
1. Write a class containing a method (must be static) to calculate size of any list.
[Put the class in /WEB-INF/classes, so your file will reside as /WEB-INF/classes/myfunctions/MyFunctions.class]
package myfunctions;
import java.util.List;
public class MyFunctions{
     public static int getListSize(List list){
          return list==null?0:list.size();
}2. In your taglib add an entry (in case you don't have already create one) for the EL function:
[Say our taglib is mytags.tld in /WEB-INF]
<taglib xmlns="http://java.sun.com/xml/ns/j2ee"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
     version="2.0">
     <tlib-version>1.0</tlib-version>
     <short-name>MyTagLib</short-name>
     <function>
          <description>List Size</description>
          <name>size</name>
          <function-class>myfunctions.MyFunctions</function-class>
          <function-signature>int getListSize(java.util.List)</function-signature>
     </function>
</taglib>3. Now in your JSP add following line to use your new EL function:
<%@taglib uri="/WEB-INF/mytags.tld" prefix="mt"%>4. And use as:
<input type=text value="${mt:size(requestScope.myList)}" />Note that there no issues using JSTL EL functions. My intention is to resolve your problem and at the same time to give you a glance how to write and use your own EL functions (might be useful in future).
Thanks,
Mrityunjoy

Similar Messages

  • How can i generate xml like this?

    Hi all,
    How can i generate xml like this & i need to send it to via HTTP :
    <mms>
                 <subject>message subject</subject>
                 <url_image>http://image_url</url_image>
                 <url_sound>http://sound_url</url_sound>
                 <url_video>http://video_url</url_video>
                 <text>message text</text>
                 <msisdn_sender>6281XYYYYYY</msisdn_sender>
                 <msisdn_receipient>6281XYYYYYY</msisdn_receipient>
                 <sid>to be define later</sid>
                 <trx_id>Unique number</trx_id>
                 <trx_date>yyyyMMddHHmmss</trx_date>
                 <contentid>see note</contentid>
    </mms>& how can i get the value of the sid (for example)?
    I hav tried to generate that xml by using StringBuffer & append, but it's not what i mean...
    Anyone can help me?

    Ok...i got it. But i still hav some problems.
    This is the sample code that i used :
    public class XMLCreator {
         //No generics
         List myData;
         Document dom;
            Element rootEle, mmsEle, mmsE;
            StringWriter stringOut;
            mms mms;
         public XMLCreator(String subject, String image, String sound,
                    String video, String text, String sender, String recipient,
                    int id, String date, String contentid) {
              mms = new mms(subject, image, sound, video, text, sender,
                            recipient, id, contentid, date);
                    createDocument();
         public void run(){
              createDOMTree();
              print();
         private void createDocument() {
              //get an instance of factory
              DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
              try {
              //get an instance of builder
              DocumentBuilder db = dbf.newDocumentBuilder();
              //create an instance of DOM
              dom = db.newDocument();
              }catch(ParserConfigurationException pce) {
                   //dump it
                   System.out.println("Error while trying to instantiate DocumentBuilder " + pce);
         private void createDOMTree(){
              //create the root element <Mms>
              rootEle = dom.createElement("mms");
              dom.appendChild(rootEle);
              createMmsElement(mms);
         private Element createMmsElement(mms b){
              Element subjectEle = dom.createElement("subject");
              Text subjectText = dom.createTextNode(b.getSubject());
              subjectEle.appendChild(subjectText);
              rootEle.appendChild(subjectEle);
              //create url_image element and author text node and attach it to mmsElement
              Element imageEle = dom.createElement("url_image");
              Text imageText = dom.createTextNode(b.getUrl_image());
              imageEle.appendChild(imageText);
              rootEle.appendChild(imageEle);
              // & etc....
              return rootEle;
          * This method uses Xerces specific classes
          * prints the XML document to file.
         private void print(){
              try
                   //print
                   OutputFormat format = new OutputFormat(dom);
                   format.setIndenting(true);
                            stringOut = new StringWriter();
                   //to generate output to console use this serializer
                   XMLSerializer serializer = new XMLSerializer(stringOut, format);
                   //to generate a file output use fileoutputstream instead of system.out
                   //XMLSerializer serializer = new XMLSerializer(
                   //new FileOutputStream(new File("mms.xml")), format);
                   serializer.serialize(dom);
              } catch(IOException ie) {
                  ie.printStackTrace();
            public String getStringOut() {
                return stringOut.toString();
    }when i tried to show the stringOut.toString() in my jsp, it's only showed string like this :
    The Lords Of The Ring http://localhost:8084/movie/lotr.3gp 6281321488448 6281321488448 123 0 20070220114851 LOTR.
    1. Why this is happen?i want to generate xml which its format is like above.
    2. How can i send this xml (put in msg parameter) using jsp (via web) without creating the mms.xml?
    3. if i want to set the msg parameter equal to mms.xml - means that msg = mms.xml, what is the data type for msg? is it an object or anything else?
    Thx b4 in advance...

  • My password protected phone was stolen and hacked into.  How can I prevent someone like this from hacking into/getting around the passcode?  They now have access to everything on my phone (I had a passcode to prevent this)

    How can you prevent a hacker from bypassing your iphone passcode?  My phone was stolen and someone hacked in and has access to everything on my phone and turned off "find my iphone."  This is exactly what I wanted to prevent from happening and the reason why I had a passcode. 

    Turn on "Erase Data" in Settings>Passcode. That will wipe the data after 10 incorrect password attempts.
    Turn off "Simple Passcode" in the same place and use something other than a 4 digit pin as your passcode.
    Also make sure Find my iPhone is enabled so you can locate and if necessary, forcibly wipe the phone.

  • How can i produce xml like this ?

    <mms>
    <subject>message subject</subject>
    <url_image>http://image_url</url_image>
    <url_sound>http://sound_url</url_sound>
    <url_video>http://video_url</url_video>
    <text>message text</text>
    <msisdn_sender>6281XYYYYYY</msisdn_sender>
    <msisdn_receipient>6281XYYYYYY</msisdn_receipient>
    <sid>to be define later</sid>
    <trx_id>Unique number</trx_id>
    <trx_date>yyyyMMddHHmmss</trx_date>
    <contentid>see note</contentid>
    </mms>
    How can i produce that xml?
    Can i produce it with this?
    public Element getXML(Document document) {
            // create sentContent Element
            Element sentContent = document.createElement( "mms" );
            // create subject Element
            Element temp = document.createElement( "subject" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getJudulFilm() ) ) );
            sentContent.appendChild( temp );
            // create url_image Element
            temp = document.createElement( "url_image" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create url_sound Element
            temp = document.createElement( "url_sound" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create url_video Element
            temp = document.createElement( "url_video" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getUrl_video() ) ) );
            sentContent.appendChild( temp );
            // create text Element
            temp = document.createElement( "text" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create msisdn_sender Element
            temp = document.createElement( "msisdn_sender" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getMsisdn() ) ) );
            sentContent.appendChild( temp );
            // create msisdn_recipient Element
            temp = document.createElement( "msisdn_recipient" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getMsisdn() ) ) );
            sentContent.appendChild( temp );
            // create sid Element
            temp = document.createElement( "sid" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getSid() ) ) );
            sentContent.appendChild( temp );
            // create trx_id Element
            temp = document.createElement( "trx_id" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getTrx_id() ) ) );
            sentContent.appendChild( temp );
            // create trx_date Element
            temp = document.createElement( "trx_date" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getTrx_date() ) ) );
            sentContent.appendChild( temp );
            // create contentid Element
            temp = document.createElement( "contentid" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getContentid() ) ) );
            sentContent.appendChild( temp );
            return sentContent;
        }& how can i send it to the server using HTTP request post method?

    <mms>
    <subject>message subject</subject>
    <url_image>http://image_url</url_image>
    <url_sound>http://sound_url</url_sound>
    <url_video>http://video_url</url_video>
    <text>message text</text>
    <msisdn_sender>6281XYYYYYY</msisdn_sender>
    <msisdn_receipient>6281XYYYYYY</msisdn_receipient>
    <sid>to be define later</sid>
    <trx_id>Unique number</trx_id>
    <trx_date>yyyyMMddHHmmss</trx_date>
    <contentid>see note</contentid>
    </mms>
    How can i produce that xml?
    Can i produce it with this?
    public Element getXML(Document document) {
            // create sentContent Element
            Element sentContent = document.createElement( "mms" );
            // create subject Element
            Element temp = document.createElement( "subject" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getJudulFilm() ) ) );
            sentContent.appendChild( temp );
            // create url_image Element
            temp = document.createElement( "url_image" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create url_sound Element
            temp = document.createElement( "url_sound" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create url_video Element
            temp = document.createElement( "url_video" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getUrl_video() ) ) );
            sentContent.appendChild( temp );
            // create text Element
            temp = document.createElement( "text" );
            temp.appendChild( document.createTextNode("") );
            sentContent.appendChild( temp );
            // create msisdn_sender Element
            temp = document.createElement( "msisdn_sender" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getMsisdn() ) ) );
            sentContent.appendChild( temp );
            // create msisdn_recipient Element
            temp = document.createElement( "msisdn_recipient" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getMsisdn() ) ) );
            sentContent.appendChild( temp );
            // create sid Element
            temp = document.createElement( "sid" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getSid() ) ) );
            sentContent.appendChild( temp );
            // create trx_id Element
            temp = document.createElement( "trx_id" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getTrx_id() ) ) );
            sentContent.appendChild( temp );
            // create trx_date Element
            temp = document.createElement( "trx_date" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getTrx_date() ) ) );
            sentContent.appendChild( temp );
            // create contentid Element
            temp = document.createElement( "contentid" );
            temp.appendChild( document.createTextNode(
            String.valueOf( getContentid() ) ) );
            sentContent.appendChild( temp );
            return sentContent;
        }& how can i send it to the server using HTTP request post method?

  • How Can I write Query like this

    My Dears:
    I want to reduce some formula in my report by merge these formula in my query
    I want to know how can I wrirte a query in query
    for example
    select empno,ename,(select sal from emp ee where ee.empno=mm.empno ) from emp mm
    the previous query I know it not logic but I need the way
    my DB 10G r2
    thanks in advance

    Apart your remark nothing seems to be wrong with your query. Did you try it?
    Regards
    Etbin

  • How can I make navigation like this...?

    http://timeger.com/work/JoseCuervo/JoseCuervo_Facebook.php
    I want to the user to be able to navigate within my site, like the navigation on this site. (the numbers on the right side of the screen re-populate the area with different images.)
    Thanks so much!

    Use mouse rollover with two images, one with just the text and the other image, rollover, with the oval around the text. You can link the first image to the page you want. This demo page has some examples: Mouse Rollover. The first two examples are hyperlink to other pages.
    OT

  • How can i render table like this

    anybody knows how i can render table like below
    header | header | header|
    cmbbox | cmbbox | cmbbox| <-- for sorting purpose
    header | header | header|
    data[][]....(content)
    plz anyone urgent!!

    anybody knows how i can render table like below
    header | header | header|
    cmbbox | cmbbox | cmbbox| <-- for sorting purpose
    header | header | header|
    data[][]....(content)
    plz anyone urgent!!

  • How can I format paragraphs like this?

    I am a novice DW user and a novice at web design.  I have a formatting challenge as follows.  First my stylesheet and then the problem:
    Could you please help me?  I have this need well more than 1,000 places on my website.  The insets vary, i.e. sometimes the first Line is inset 80px and the second and following Lines 120px, etc.  Again, I don't understand much of this so please be explicit.  Thanks very much!

    Your insertion didn't come through.  Ca you post a link to your web site?  Or use the camera icon in the web forum to upload an image into your post showing how you want to format paragraphs.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • How can I join images like this

    I have downloaded many wallpaper images and they come in left.jpg and right.jpg packs (I use dual monitors) and I would like to join them together but it takes too long in Gimp, as the process is Image > Canvas size, resize, then paste and align and save. Is there a quick CLI way or something to do this ?? What would be the method? Much appreciated if possible, thanks.

    tesjo,
    Thank you so much!! I was fiddling with it and kept messing it up trying -append and -adjoin. That works perfect, thanks a lot

  • How can I format paragraphs like this? -with missing image i hope

    I am a novice DW user and a novice at web design.  I have a formatting challenge as follows.  First my stylesheet and then the problem:
    For a larger image go to my website at    www.schembs.com/Left_Margin_Problem.png
    Could you please help me?  I have this need well more than 1,000 places on my website.  The insets vary, e.g. sometimes the first Line is inset 80px and the second and following Lines 120px, or 120 and 160, etc.  Again, I don't understand much of this so please be explicit.  Thanks very much!
    jds

    Thanks.  But is there a difference between what you are proposing:
    .indent {
             padding left: 200px;
    And what I already have?
    .col_5 {
              padding-left: 200px;
              padding-right: 50px
    And if I put a <p><span......> I get a blank line between my Line 1 and Line 2.  The <p> causes the blank line.
    With just a <br /> (and no <p>)  and then the <span class="col_5" the "col_5" command just is acting on the next line as in Example B.  Actually class="col_5" is additive to the previous class="col_4" callout, and therefore the indenting is 160px plus 200px or 360px.  In my Example B I used "col_1" after the "col_4" and get an indent of 160px plus 40px or 200px.
    Please look at:
    http://www.schembs.com/Left_Margin_Problem.png
    Jim

  • How can I show somehting like this?

    [opt1] [opt2] [opt3] [opt4]
    | Main Panel |
    | |
    | Sub Panel |
    | |
    Where opt1, opt2,... are tabs. When user click on different tabs, only Sub Panel will change.
    Main Panel will always stays the same.
    I was thinking about let Main Panel on TOP of a JTabbedPanel, and that JTabbedPanel has blank upper side.
    Is this possible?

    Well, the easiest way to do this, is using a JTabbedPane with tab location set to bottom ... ;-)
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JTabbedPane.html#setTabPlacement(int)
    Another way to go about this would be to use a CardLayout for SubPanel and represent opt1 to opt4 by JButtons with an ActionListener or JComponents on which you register a MouseListener, then switch cards when the button or the component is clicked.

  • Hi, I need to remove that disease of a yahoo toolbar from my bookmarks toolbar. Just like windows it wont go away when I try to remove it, how can I get rid of this menace?

    I cant get rid of the yahoo bookmark in my bookmarks toolbar, just like a disease it wont just go away, how can I get rid of this pest?

    Hi,
    You can try the suggestion posted here: [https://support.mozilla.com/en-US/questions/682742]
    If that doesn't work, please describe what happens when you follow those steps.
    Good luck!

  • In Mail, one mailbox for Recovered Message (AOL) keeps showing 1 very large message that I cannot delete. How can I get rid of this recurring problem, please?

    In Mail on iMac, successfully running OS X Lion, one mailbox on My Mac for "Recovered Messages (from AOL)" keeps showing 1 very large message (more than 20 Mb) that I just cannot seem to delete. Each time I go into my In Box, the "loading" symbol spins and the message appears in the "Recovered Messages" mailbox. How can I get rid of this recurrent file, please?
    At the same time, I'm not receviving any new mails in my In Box, although, if I look at the same account on my MacBook Pro, I can indeed see the incoming mails (but on that machine I do not have the "recovery" problem).
    The help of a clear-thinking Apple fan would be greatly appreciated.
    Many thanks.
    From Ian in Paris, France

    Ian
    I worked it out.
    Unhide your hidden files ( I used a widget from http://www.apple.com/downloads/dashboard/developer/hiddenfiles.html)
    Go to your HD.
    Go to Users.
    Go to your House (home)
    there should be a hidden Library folder there (it will be transparent)
    Go to Mail in this folder
    The next folder ( for me ) is V2
    Click on that and the next one will be a whole list of your mail servers, and one folder called Mailboxes
    Click on that and there should be a folder called recovered messages (server) . mbox
    Click on that there a random numbered/lettered folder -> data
    In that data folder is a list of random numbered folders (i.e a folder called 2, one called 9 etc) and in EACH of these, another numbered folder, and then a folder called messages.
    In the messages folder delete all of the ebmx (I think that's what they were from memory, sorry I forgot as I already deleted my trash after my golden moment).
    This was GOLDEN for me. Reason being, when I went to delete my "recovered file" in mail, it would give me an error message " cannot delete 2500 files". I knew it was only 1 file so this was weird. Why 2500 files? Because if you click on the ebmx files like I did, hey presto, it turned out that they were ALL THE SAME MESSAGE = 2500 times. In each of those folders in the random numbers, in their related message folder.
    Now remember - DONT delete the folder, make sure you have gone to the message folder, found all those pesky ebmx files and deleted THOSE, not the folder.
    It worked for me. No restarting or anything. And recovered file. GONE.
    Started receiving and syncing mail again. Woohoo.
    Best wishes.

  • Hi everyone,,i bought a used iphone 5 with iOs 7.0.3. i want to delete the icloud account and add mine. I have sent an e-mail to the current account being used in my iphone. How can i get rid of this account plzzz help me out

    Hi everyone,,i bought a used iphone 5 with iOs 7.0.3. i want to delete the icloud account and add mine. I have sent an e-mail to the current account being used in my iphone. How can i get rid of this account plzzz help me ou

    no i called the store owner from whom i bought it. he was like i will check in records and if there is something i will let u know...he was like send an e-mail its better so if it was stolen so the shopkeeper wouldnt let me to e-mail to the owner

  • How to make a photo like this? (footballer)

    Dear All,
    I am enclosing a photo that I found in the Internet. This is a footballer photo.
    May I know how I can make a photo like this in terms of color and texture in Photoshop? Many thanks!
    Best regards,
    Keith

    What you'll want to do is pick a photo with something like a person or an animal in the foreground. Then, use the Lasso tool to trace around the outside. Separate the person and the background into two or more layers, depending on how much you want to change. Up the saturation on the background, and apply a blur under the filter menu. It might just be the angle the photo was taken from, but they could have possibly added a light effect behind him as well. As for the guy, it looks like they upped the contrast and lowered brightness. Since i don't know from what angle the photo was taken, those are the only effects I can say were most likely used.
    Hope this helps,
    Cole

Maybe you are looking for

  • ALV grid to protected Excel sheet

    Hi ABAP gurus, I Have developed an ALV report using OO concept and from the application toolbar i am able to change  the GRID output to Excel output using View -> Excel inplace. Belows are my requirement now. 1. I need to change the standard template

  • Nokia lumia 520 is nt support fm radio

    I was update the Lumia amber in my Lumia 520 bt I cant see any change in settings and I cant acess fm plzz help me I want fm... Not show amber in extra info... I cant see any change in enhancement allsa plzzz help me Solved! Go to Solution.

  • Anyconnect permission with NT Domain user

    Hi, I am trying to setup a VPN with AnyConnect on my ASA5510 and it works fine.  I have setup an AAA server group for my Active Directory with the "NT Domain" protocol".  Right now, every user is able to connect with their Active Directory credential

  • 5508 WLC-6500 Series Switch Etherchannel

    Hi, I have a 5508 controller connected to a 6500 VSS pair. Below is the port channel configuration and port configuration.  I am just wondering whether we still have to configure a load balancing method as cisco recommends "port-channel load-balance

  • ICM Scripting Error Handling Best Practice

    Can someone tell me what is the best way to handle errors in ICM scripting. For example false node on Send to VRU or Run Ext Script node, I normally handle this with calltypes for errors and then continue the callflow. But recently I noticed that som