• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Help translate to JSTL and EL

 
Ranch Hand
Posts: 355
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Also, you do not need to create a list class. By the way, you'd just use ArrayList to collect the individual beans,


Bear,
I have made the change already. By the way, is there any difference? My jsp page in which i want to translate the scriptlets to jstl and el is as follows:

 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Ngom wrote:By the way, is there any difference?


Difference between what?

What did you end up naming the bean?

My jsp page in which i want to translate the scriptlets to jstl and el is as follows:



First steps:
  • Make sure that your controller places the List in request scope so that it is available to the JSP. I'd suggest a good name such as stockList or something else that describes the list well.
  • Get rid of the getAttribute() call. It is not needed. Scoped variables are automatically available to the JSP by their name. E.g. stockList if that's what you use.
  • Replace the while loop with the <c:forEach> tag. Look up this tag -- it works very much like the ehnanced for loop in Java.


  • Then we'll move on from there.
     
    Paul Ngom
    Ranch Hand
    Posts: 355
    1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Bear,
    I have tried this and it is giving me a blank page. Any idea of the root cause?

    The server log says: The end tag "</c:if" is unbalanced
     
    Bear Bibeault
    Sheriff
    Posts: 67637
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Two things: you're losing your indentation again. I'm not inspecting unindented code.

    And your code is full of invalid markup. Tags that aren't closed and so on. And why do you still have tags in the code? We cannot move forward until you have addressed the issues that have already been brought up previously. And cleaning up the code is essential to moving forward.

    A blank page is also usually an indication that an exception has occurred. Be sure that you are looking at the log file to see if exceptions are occurring on the server.
     
    Bear Bibeault
    Sheriff
    Posts: 67637
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    The server log says: The end tag "</c:if" is unbalanced


    Then it probably is. Cleaning up the code by using proper indentation and removing invalid and unnecessary markup should help reveal the structural problems.

    I'm not harping on properly formatted code just for giggles -- it's an essential tool in revealing the structure of the code and revealing problems with that structure.
     
    Marshal
    Posts: 27214
    87
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    One more thing:



    It looks like you plan to have a counter which will tell you when you are processing the first row of the list. You don't have to do this yourself; the <c:forEach> tag has an attribute which will provide this counter for you. Check out the documentation for that tag.
     
    Paul Ngom
    Ranch Hand
    Posts: 355
    1
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator


    It looks like you plan to have a counter which will tell you when you are processing the first row of the list. You don't have to do this yourself; the <c:forEach> tag has an attribute which will provide this counter for you. Check out the documentation for that tag.


    Thanks a lot Paul.
     
    Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
    Free, earth friendly heat - from the CodeRanch trailboss
    https://www.kickstarter.com/projects/paulwheaton/free-heat
    reply
      Bookmark Topic Watch Topic
    • New Topic