Scriplet

hi friends,
goodday. i had some problem in understanding this part of the code. could you plz help me here. the following scriplet is the part of jsp and just after the odject declaration, some method is written. what does this signify?
<%
          ISearcher.IFieldValueProcessor scopeProcessor =
               new ISearcher.IFieldValueProcessor() {
                    public Object processFieldValue( String fieldId, Object value ) {
                         String scopeLabel = (String)value;
                         return userSpecificScopes.getCategoryIdArrForScope(scopeLabel);
     %>thanks

int i=0;
declares an integer (whole number) called i
out..println(i);
prints i out to the screen, i.e. 0 will be printed to screen.
If you used int i = 99, then 99 would be printed to the screen.
Also you have written this out wrong, there is only one point between out and println:
out.println(i); NOT
out..println(i);
i=i+1;
Adds 1 to i, so if i = 0 before this line, i = 1 afer this line.

Similar Messages

  • Help putting a scriplet in a jsp

    I have the following jsp page which i have created a scriplet inside which should go around the arraylist and pull the data into a table but i am getting a error message when trying this the jsp is:
    <BODY BGCOLOR>
         <jsp:usebean id="pricePassed"
                   class ="MySite.displayBean"
                   Scope="request"     />
           <p><center><img src="image.jpg" width="350" height="200" /> </center></p>
         <h1>The price ranged is </h1>
         <h2><font color="white"><B><U> <jsp:getProperty name="pricePassed" property="pricePassed" /> </U></B></font></h2>
    <P>
    <center><a href="http://localhost:8080/examples/home.html
    ">Back</a></center>
    <% = Iterator it = collection.iterator();
    while( it.hasNext() ){
       videoBean vids = (videoBean) it.next();
       out.println( "<TR>" +
                    "<TD>" + vids.getTitle() + "</TD>" +
                    "<TD>" + vids.getDirector() + "</TD>" +
                    "<TD>" + vids.getRating() + "</TD>" +
                    "<TD>" + vids.getYearReleased() + "</TD>" +
                    "<TD>" + vids.getPrice() + "</TD>" +
                    "<TD>" + vids.getStockCount() + "</TD>" +
                    "<TD>" + vids.getImageName()  +"</TD></TR>\n" );
    } %>
    </body>
    </html>The error says:
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    An error occurred between lines: 9 and 16 in the jsp file: /display.jsp

    thanks not sure it this is better or worse lol but now i get :
    org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
    An error occurred between lines: 16 and 27 in the jsp file: /display.jsp
    Generated servlet error:
    D:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\examples\display$jsp.java:65: Class org.apache.jsp.Iterator not found.
                      Iterator it = collection.iterator();
                      ^
    An error occurred between lines: 16 and 27 in the jsp file: /display.jsp
    Generated servlet error:
    D:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\examples\display$jsp.java:65: Undefined variable or class name: collection
                      Iterator it = collection.iterator();
                                    ^
    An error occurred between lines: 16 and 27 in the jsp file: /display.jsp
    Generated servlet error:
    D:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\examples\display$jsp.java:67: Class org.apache.jsp.videoBean not found.
                       videoBean vids = (videoBean) it.next();
                       ^
    An error occurred between lines: 16 and 27 in the jsp file: /display.jsp
    Generated servlet error:
    D:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\examples\display$jsp.java:67: Class org.apache.jsp.videoBean not found.
                       videoBean vids = (videoBean) it.next();
                                         ^
    4 errors, 1 warning

  • Hi..assign a core tag value to a variable in jsp scriplet

    Hi
    I have a <core:set var="membershipType" value="${somevar}" />I want to set the membershipType value of the above tag to a variable in scriplet <% String member =""%> How can I do that,
    Any ideas
    Thanks
    jag

    EL variables are assigned to one of the 4 scopes -> Page, Request, Session, or Application. By default they go to the page scope, which corresponds to the pageContext object in scriptlets.
    The result is that you need to retrieve the value out of the scope it is in using the proper getAtribute(name) method, such as:
    <% String member = pageContext.getAttribute("membershipType") %>The best course of action, though, is re-designing your application so there is no need for scriptlets.

  • Jsp and jspx and scriplets - Hiding buttons based on J2EE security roles

    Hello:
    I have security a scoped managed bean with methods is Technician(), isUser() etc. In the jsp world, it was very easy to inspect these methods in the jsp via scriplets and show/hide buttons/links etc. I am just curious. Or, is rendering via EL expression the way to go?
    (1) In the jspx world (SRList.jspx in my case), is there an easy way to inspect these managed bean methods and use scriplets to access them and show/hide buttons.
    In the jsp world, I would have written something like
    if (SecurityInfo.isTechnician()
    { %>
    <Button>
    <% } %>
    There would be an import statement to have access to SecurityInfo class in jsp world. I know something is out there in the ADFBC/jspx world. Please advice? If you know of any urls, please let me know.
    (2) Is there a way to grant read/write access to individual pages in my app? I can hide/view buttons based on roles but can't grant update/view access to individual fields on my pages. I know I have to wait for JDEV 11 release to grant permissions via pagedef/iterator as is done in file based security.. Any other solution till then?
    Thanks

    hi useradfbc
    about (1), you could try something like this
    <af:commandButton text="my button for managers" rendered="#{userInfo.manager}"/>(tip : You can use "Your Control Panel" to make your name visible in forum posts.)
    success
    Jan Vervecken

  • Java script and scriplets

    Hi,
    I have got a .jsp page wherein there is a 2 dimentional string array defined within a scriplet.
    I have defined an other function in java script within the same page.
    Now I need to access the string array within the java script. Can someone please hep me how to achive this...
    I tried something like this, but its not working:
    function displayNameIndex()
    var source = <%= imgArrayName %>[0][0];
    where imgArrayName is the name of the String array in the scriplet code.
    Many thanks

    JSP is executed at the serverside and generates a long HTML string. Javascript is part of this HTML string. Once this string is arrived at the client, the JS will/can be executed.
    What you're expecting here is that the Javascript is able to access the Java Object which is converted into a simple plain vanilla string. That is not true. Better is to put all of this logic in the server side or in the client side. You may need to iterate through the Java String[][] object and print all values into the response, so that JS can access them.

  • My Date Scriplet worked fine until now

    Can you please take a look at my date scriplet I wrote for a jsp page? It gives the current month, day, and year but for some reason it is saying March 16, 2002 instead of May 16, 2002.
    Any ideas would be greatly appreciated.
    Thanks,
    panatha
    <%@page import="java.util.*" %>
    <%
    String month[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
    Calendar cal=Calendar.getInstance();
    %>
    <%
    out.print(month[Calendar.MONTH]+" ");
    out.print(cal.get(Calendar.DATE)+" ");
    out.print(cal.get(Calendar.YEAR)+" ");
    %>

    How can the value of month always be 2? Won't Calendar cal=Calendar.getInstance(); take the current value?
    I used this scriplet because I wasn't successfully able to use anything else so it could display the month, day, and year. The others would only display them one way with the addition of the time. What do you think the best way to display month, day, year is?
    Thanks a lot for your response.
    panatha

  • JSTL forEach tag taking longer time than scriplets ???

    Hi Gurus,
    My STRUTS action class setsup a collection object [roughly 900 + records stored as java beans] to be displayed on my view [JSP]. The problem is, when I iterate over this collection in JSP using <c:forEach> tag, it takes around 4-5 minutes to build up the page.
    I coded the same looping logic through java scriplets embedded within JSP and the processing came down to 1 minute. Should I assume that <c:forEach> tag will have a processing overhead over plain java code in JSP?
    FYI, I checked the server generated SERVLET code under WORK directory of TOMCAT for this JSP with <c:forEach> tag and find lot of code being generated for this <c:forEach> tag implementation. Could it be that the processing of these generated code takes longer than plain java using scriplets?
    Please Help.
    Thanks,
    Karthik.
    <b>JSP using <c:forEach></b>
    <c:forEach var="refurb" items="${BOMDataForm.refurbSummary}" varStatus="loopStatus">                    
    <tr valign="top" bgcolor="#FFFFFF"> 
    <td>
    <div align="center"><span class="modulecontent"><c:out value="${refurb.configName}" /></span></div>
    </td>                     
    <td>
    <div align="center"><span class="modulecontent"><c:out value="${refurb.itemName}" /></span></div>
    </td>
    </tr>
    </c:forEach><b>JSP using embedded scriplets</b>
    <%
    BOMDataForm bomDataForm = (BOMDataForm) request.getAttribute("BOMDataForm");
    ArrayList arrayList = (ArrayList) bomDataForm.getRefurbSummary();
    int loop = arrayList.size();
    for (int i=0;i<loop;i++) {
    out.println("<tr valign=\"top\" bgcolor=\"#FFFFFF\">");
    out.println("<td>");
    out.println("<div align=\"center\"><span class=\"modulecontent\">");
    out.println(((RefurbSearchResult)arrayList.get(i)).getConfigName());
    out.println("</span></div>");
    out.println("</td>");
    out.println("<td>");
    out.println("<div align=\"center\"><span class=\"modulecontent\">");
    out.println(((RefurbSearchResult)arrayList.get(i)).getItemName());
    out.println("</span></div>");
    out.println("</td>");
    out.println("</tr>");                         
    %>

    Never looked at the speed issues. For me it has always been "fast enough"
    When displaying pages with 900 records on it the common approach is to split the result across multiple pages, so that loading doesn't get too long.
    The JSTL tags obviously introduce some overhead in extra procedure calling. As you found out by looking at the generated servlet code.
    Also the EL expressions have to be evaluated. using the reflection APIs. Its pretty certain that direct access to the object is faster.
    The forEach tag uses an iterator under the hood, where you are calling get(i) directly on an ArrayList.
    Any or all of these would be contributing. My guess would be the EL expression evaluation is probably the most overhead.
    One thing about your example I would like to see is how long it would take using an Iterator, rather than calling get(i) on the array elements. That would remove at least one of the differences.
    So in short, yes the JSTL is adding overhead to your page. I'm a bit surprised to hear it is so much though.
    Cheers,
    evnafets

  • Can't get JSF scriplet value.

    Hi all...
    I have a problem here when i'm applying EJB with JSF.
    Here is my code.
    EJB project
    package com.ejb;
    import javax.ejb.Remote;
    @Remote
    public interface daoCalculator {
         String getMessage();
    package com.ejb;
    import javax.ejb.Stateful;
    import com.ejb.daoCalculator;
    public @Stateful
    class daoCalculatorBean implements daoCalculator {
         public daoCalculatorBean() {
         public String getMessage() {
              if ((Math.random() * 10) > 5) {
                   return "Hello EJB World~!";
              } else
                   return "THis is not 0 !";
    _This is the JSF managed bean_
    package com.web;
    import javax.faces.event.ActionEvent;
    import com.ejb.*;
    import javax.ejb.*;
    * @author samuel
    public class intCalculator {
         @EJB (name="daoCalculatorBean/remote") private daoCalculator cart;
         String text;
         String text2;
         String text3;
         public intCalculator() {
         /*     try {
                   InitialContext ctx = new InitialContext();
                   cart = (daoCalculator) ctx.lookup("daoCalculatorBean/remote");
              } catch (Exception n) {
                   System.out.println(n);
         public String getText3() {
              return text3;
         public void setText3(String text3) {
              this.text3 = text3;
         public String getText2() {
              return text2;
         public void setText2(String text2) {
              this.text2 = text2;
         public String getText() {
              return text;
         public void setText(String text) {
              this.text = text;
         public void present(ActionEvent e) {
              text = cart.getMessage();
              text2 = cart.getMessage();
    }In my web-page(presentation layer), I'm able to get EJB function's value.
    But i can't use scriplet to retrieve "#{intCalculator.text3}".
    This is weird, because i can get this value if just apply Dynamic Web Project without EJB project.
    Did anyone face the same problem? Please kindly advice or share experience.
    Thanks in advance :)

    Hi...
    I think i shall explain my program.
    Actually I'm trying to implement JSF + EJB together.
    Initially, I just implement JSF and everything works fine. In managedBean (using session scope), i can create getter & setter with functions also and these items are retrievable in my JSP page with scirplet only ---> "#{managedBean.variableORfunction}"
    But this no longer happen with I implement EJB into it.
    here is the extra code for JSP side.
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
         <h:panelGrid border="1" columns="2">
              <h:outputText value="1st"></h:outputText>
              <h:inputText value="#{intCalculator.text }"></h:inputText>
              <h:outputText value="2nd"></h:outputText>
              <h:inputText value="#{intCalculator.text2 }"></h:inputText>
              <h:outputText value="3rd"></h:outputText>
              <h:inputText value="#{intCalculator.text3}"></h:inputText>
         </h:panelGrid><h:form>
              <h:commandButton value="Press Me Pls~!" actionListener="#{intCalculator.present}"></h:commandButton>
              <h:commandButton value="Go Next Page~!" action="welcome"></h:commandButton>
         </h:form>
    </f:view>
    </body>
    </html>Usually if we implement only JSF, then intCalculator will be in the managed bean, text, text2, text3 will be in intCalculator with getter & setter. And in JSP page as above, we just need to place as above code. When the button "Press Me Pls~!" is trigger(press), then it shall redirect to the same page(because as above this button does not direct to any other page) and show the above text,text2 and text3 values right? (I mean if i just implement JSF only).
    Example:- if i type as below (ps: This is only with JSF)
    text = "Hello"
    text2 = "EJB"
    text3 = "JSF"
    then, it shall display in the textfields with the above values.(because it already store in intCalculator managedbean when button is pressed)
    But the problem occur when i implement EJB + JSF together. (ps: EJB + JSF)
    the managedBean seems like lost function. It couldn't store the value into the getter & setter in my managedBean.
    Fyi, I can call the function from sessionBean(EJB). (just try to prove that JNDI lookup is well done)
    I suspect the sessionBean(EJB) already created a sessionID and cause the managedBean session scope does not performing well. Is this possible? Is there any better approach for this solution?
    THanks for all of your time =D
    Do share experience if meet this kind of cases before. =D

  • Remove all Scriplets ??  and change to tags.

    I have a shopping cart aproximately 2 years old that is jsp/servlet.
    The jsp pages look more like servlets as they have TONS of java code in them.
    The shopping cart currently has no taglibs in it, and I am in the process of re-writing all jsp pages.
    Is there an easy way or good tutorial to convert these scriplets into nice tags ?? I have had success in creating simple tags to connect to database on first page, but not sure if I am going in right direction.
    or do I just keep trying google till I stumble on something.??
    Should I post an example jsp page of the sriplet code??

    My brain is turned off today, having a tuff time starting it..
    Here is the beginning of the shopping.jsp, first page a user would see.
    <%
              shopping.jsp
         String shoppingServlet = (String) session.getAttribute("shoppingServlet");
           System.out.println("Shopping servlet path : " + shoppingServlet);
         ItemBean[] items = (ItemBean[]) session.getAttribute("items");
         String isFromCredit = (String) session.getAttribute("isFromCredit");
         Formatter formatter = new Formatter();
    %>
    <!--some html stuff -->
    <form name='form' action='<%= shoppingServlet%>' method='post'>
    <!--some more html stuff -->
    <%     for (int i=0; i < items.length; i++) {
                   ItemBean item = (ItemBean) items; %>
              <tr height=10>
                   <td valign='middle'>
                        <a href='/shopping/description.jsp target='product'
                             onClick='window.open("/shopping/description.jsp?item=<%= item.getID()%>", "product", "toolbar=no,status=no,height=500,width=650,scrollbars=yes,resizable=no");return false'>
                             <%= item.getName() %>
                        </a>
                   </td>
                   <td valign='middle'>
                        <%= item.getShortDesc() %>
                   </td>
                   <td valign='middle' align='right'>
                        <%= item.getSize() %>
                   </td>
                   <td valign='middle' align='right'>
                        <%= formatter.formatMoney(Float.toString(item.getPrice())) %>
                   </td>
                   <td valign='middle' align='center'>
                        <input type=image src='../images/addToCart.gif' alt='Add To Cart'
                             onClick='document.form.action.value="cart", document.form.itemToAdd.value="<%= item.getID() %>"'>
                   </td>
              </tr>
    How do I deal with the session attributes at top of page??
    How can I put that code into a servlet ??
    and the for loop will just be a little work on the servlet side , right ??

  • Scriplet value in custom tag attribute doesn't compile

              Using a custom tag (a BodyTag extention) in a JSP. When WebLogic 6.0 tried to compile
              it I get the following error. It compiles fine in JBuilder and runs fine in resin
              servlet server.
              Here the source line from the JSP (I even put the messy spaces in the scriplet
              since that is how WebLogic examples do it):
              <tags:SystemSearch locationName="<%= locationName %>"     customerName="<%= customerName
              %>" systemModelNumber="<%= systemModelNumber %>"     systemName="<%= systemName %>"
              locationID="<%= locationID %>" >
              Here's the line of the compile error from the WebLogic generated servlet:
              tagsSystemSearch0.setLocationID weblogic.utils.StringUtils.valueOf("<%= locationID
              //[ /SystemBrowse.jsp; Line: 66]
              Here's the related error message:
              D:\java\bea\wlserver6.0\config\darcon\applications\.wl_temp_do_not_delete\WEB-INF\_tmp_war_dev1_dev1_ROOT\jsp_servlet\_systembrowse.java:202:
              unclosed string literal
              probably occurred due to an error in /SystemBrowse.jsp line 66:
              

    This is my tag code:
    public class ErrorTag extends SimpleTagSupport {
         private static final long serialVersionUID = 1L;
         String val = null;
         private static final String DIV = "<div class=\"error\">ERROR</div>";
         private static final String INSERT_HERE = "ERROR";
         public void doTag() throws JspException {
              try{
                   PageContext pageContext = (PageContext) getJspContext();
                  JspWriter out = pageContext.getOut();
                   if(val!=null){
                        String outputDiv = DIV.replace(INSERT_HERE, val);
                        out.println(outputDiv);
                        System.out.println("out.println -> ["+outputDiv+"]");
              }catch (Exception e) {
                   System.out.println("doStartTag -> ["+e.getMessage()+"]");
         public void setValue(Object value){
              System.out.println("setValue -> ["+value+"]");
              if(value!=null && value instanceof String){
                   String t = (String)value;
                   if(t.trim().length()>3){
                        val = t;
         public Object getValue(){
              return val;
    }I don't know waht to do. It doesn't want to eval EL expr.
    It produces output:
    *setValue -> [${errors.name}]*
    *out.println -> [<div class="error">${errors.name}</div>]*
    Edited by: Holod on 21.06.2009 15:12

  • Irrational fear of scriplets - revisited

    hey all this is a continuation of a very long thread that begins here
    http://forum.java.sun.com/thread.jsp?forum=45&thread=318105. (if you read it, remember to post any continuations on this thread.
    My basic contention is that small scriptlets which do things like get values from beans, or do simple conditionals are fine and that forcing people to use the tag libraries which do these things is not productive. For the record, I advocate MVC, I advocate good architecture, But the debate about tags vs WELL-DESIGNED scriplets usage (i.e. a line or two which call a bean or regular java class, or just does a loop over some collection)is not about architecture it about syntax, and the ethereal concept of readability. (And fear.)
    Why do they exist then?
    Managers want to make the sofware development process faster and cheaper. Architects somewhere along the line have sold them the notion that a syntax that has carets in it is somehow easier to learn (dumb manager says, "hey that looks like HTML, must be just as easy", sleazy tag salesman says,"oh yeah, it is. Your dog could do web apps now"). The management team then thinks about the savings they could reap with pound puppies. The big flaw in all this is that these tags are not easier to understand than the scriplet which would do the same thing. Why invest time in learning this library of arcane Collection management tags, when a scriplet would just be standard java. Standard Java is here to stay, the Expression Language (EL) and some of the more pointless libraries are a little more "iffy", and consequently not as big an asset to ones' skill set.
    Detractors of this argument would say that these tags are intended for "nonprogrammers" or "GUI Developers", but, I'm sorry, once your dealing with hierarchies of objects with the collections tags, your programming. Like it or not. So why not use a real programming language. When james gosling invented java why didn't he do the whole thing with tags, if they're so readable? Also remember that any decent html developer, also knows javascript. How far really is the leap from javascript, to the small amount of java required to call an java class from a scriplet? One of my good hearted compatriots in the original thread suggested that The leap is too far because java is a typed language and javascript is not. Come on, that just doesn't fly. So they should read the chapter on objects, types, and casting. And then come in the next day and get to work. Whatever mental facility would need to be in place to learn the small amount of java to access a class in a scriptlet also must be in place to learn EL and collections tags. Now they're becoming java programmers and maybe architects feel they must continually reinforce the notion in the minds of management that there is an unbending hierarchy of programmers and that some people could just never do certain things. This attitude is necessary to maintain the hierarchy at the top of which the Architect presides. I guess from the management perspective, I would be upset if I taught all my html developers, java and then they all wanted more money cause now they're java developers. But then again, from the human being perspective I don't like to see the careers of others actively stunted. And besides management should have the foresight to see the possible glut of new java programmers would force rates down. It's a win-win-lose, the loser is the Architect whose rate could drop due to more java programmers being around. But he was already a loser. This argument is almost a moot point. Every project I've been on has java developers doing the pages anyway.
    I realize that in spite of all these arguments, architects will still maintain the status quo, categorizing the potential of other people into hierarchies of their liking. It's like dealing with Liberals. The main argument always seems to return to readability assertion which is rarely ever challenged, except in private by those who don't want to appear "stupid" by challenging the orthodoxy of their industry. I, However have no problem appearing stupid. And do it quite well, sometimes. Maybe I'm doing it now. I do allow that I could be totally wrong. Someone convince me.
    I always held the Unix, Linux, Java world in high regard because they refused to participate in the "Dumb it Down", "Hide The Details" approach that their major rival sells. (Tags are not really even a dumb down in my opinion).
    And the parting question. Is there a way of objectively determining readability? Who determines readability?
    p.s. check out this thread about a developers frustration with EL and then think about how much easier the scriplet solution would be.
    http://forum.java.sun.com/thread.jsp?forum=45&thread=304696

    Hi once again jfoltz2.
    Trying to raise this topic again I see. Good on you. As you know (from my postings on the original thread), I very much sympathise with you regarding the 'irrational fear of scriptlets' that seems to have infected a substantial number of JSP developers.
    It was a pity the original thread died, because while there were some quite strongly held beliefs that TAGLIBS were the bees knees. By the end there were a number of others expressing caution about blind adoption TAGLIBS (mostly from smaller teams/organizations I noticed). It's not so much that TAGLIBS are bad per se, but that they are not a panacea. I particularly enjoyed jlusk4's posting (the final one) which summarised many of my views and concerns too (hope you rediscover the thread jlusk4).
    The original thread also strongly re-enforced concerns I have about just how poorly integrated our web tools/languages are. While the details may be different for each user and application, I don't think it would be uncommon for developers of interactive web sites to use Java/JSP/TAGLIBS/XML/Databases/etc on the Server side and HTML/Javascript/DHTML/CSS/Flash/Java/etc on the Client side. Each with it's own quirks and limitations. They are far from seamlessly integrated.
    When you consider all the different browsers, browser revisions, differences in implementation between core browsers technologies (e.g. Javascript), container engines (e.g. tomcat), etc. It is clear that developing interactive web sites is difficult and not without pain, in fact it's rather surprising that it works at all. The multiplicity of languages and tools is, in my view, unnecessarily complex and cumbersome and breeds a culture of gurus and wizards (which isn't very helpful either). In short it wastes time, energy and money.
    Okay I've gone slightly off topic, so I'll try and bring it back on track. Clearly scriptlets don't help reduce the complexity of integration, but TAGLIBS don't add anything magical either. There simply represent an alternative band-aid/plaster to a more fundamental problem. We should keep this in mind when we're debating whether scriptlets vs TAGLIBS.
    Finally, from a sociological point of view, the original thread was interesting, because it demonstrated just how strongly people hold their beliefs about software design (myself included). Holding strong opinions is fine so long as you understand the others point of view and are willing to accept that you might be wrong. From that basis you can make a balanced judgement, for YOUR own work area. Being a zealot helps no one, not even yourself.
    Having said that I have to confess that I am a zealot in one way. I'm intolerant of the intolerant.
    Anyone want to take the bait ?
    Cheers,
    Jason.

  • Comparison operator is taken as scriplet by compiler !!

    Hi
    I am having following scenario in my jsp code :
    <%
    String query = "Select * from tablename where salary <=2000";
    %>When i am using above code it is actually taking '<' in <= as beginning tag of scriplet.
    Which is causing the error.
    How can i avoid this.

    Hi
    This was an error becos of IDE i was using.
    When i was clicking on this comparison operator, it wsa highlighted alongwith closing scriplet tag. And error thrown was not becoz of this, it was becoz of some other coding problem. What i thought is that error is becoz of that comparison operator only.
    But now it is resolved.
    Thanks.

  • Can we write scriplet code inside c:forEach /c:forEach

    Hi
    I am having one <c:forEach> tag
    As Given below
    <c:forEach var="holiday" items="${state.holidays}" varStatus="current">
       <tr>
          <td>${holiday.name}</td>
          <td>${holiday.date}</td>
       </tr>
    </c:forEach>now I want to apply SimpleDateFormater on ${holiday.date} before showing it on jsp.
    so
    I need to perform following operation
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy" );
    String parsedDate = df.parse(holiday.date);
    So for that code should be some this like this but
    <c:forEach var="holiday" items="${state.holidays}" varStatus="current">
       <tr>
          <td>${holiday.name}</td>
    <%
    SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy" );
    String parsedDate = df.parse(holiday.date);
    %>
          <td>${parsedDate}</td>
       </tr>
    </c:forEach>but here I am not able to get holiday inside my scriplet , how can apply SimpleDateFormat on holiday.date?
    is it possible to write scriplet inside tag?
    Please suggest me any other way if you have?
    Regards,
    Manoj

    Use the fmt:formatDate tag instead. It is based on SimpleDateFormat API.
    http://java.sun.com/products/jsp/jstl/1.1/docs/tlddocs/fmt/formatDate.html

  • From scriplets to JSTL/EL

    Hi everybody!
    I'm working on a new project given by my boss. It uses struts framework. I have to translate some scriplets into JSTL and EL code in order to reduce the code. I'm working on a page wich lists requests made by the society's administrators. I managed to translated some parts like :
    <%=webInformationBean.getOperation()%>INTO : <c:out value="${webInformationbean.operation}"></c:out>
    But I have two scriplets wich i didn't manage to translate...Here are the code and some explanations :
    <center><%=frcGatewaySrsBean.getFrcGatewaySrsDtos().length%> requetes selectionn�es</center>frcGatewaySrsBean is a java bean and frcGatewaySrsDtos a bean property wich is a table of frcgatewayDrsDto objects. This table contains the administrators' requests that's why we can retrieve the length of this table. But i can't translate it:(
    Then, here is the second problem:
    <% for (int i=0;i<frcGatewaySrsBean.getFrcGatewaySrsDtos().length;i++){%>
    <tr class="normal">
      <td><b><%=FrcGatewaySrsBean.getLong(frcGatewaySrsBean.getFrcGatewaySrsDtos().getFrcGatewaySrsId())%></b></td>
    </tr>
    <%}%>
    getFrcgatewaySrsDtos retrieves the table of frcGatewaySrsDto objects.
    <%=FrcGatewaySrsBean.getLong(frcGatewaySrsBean.getFrcGatewaySrsDtos().getFrcGatewaySrsId())%>  means that we retieves the identifier of an object wich is at the position i of the table called frcGatewaySrsDtos. I can't translate it because i dont know how to translate a method wich has parameters.
    Please help me! Thanks!

    Which server are you using?
    There are two issues here
    1 - getting the size of a collection/array
    2 - calling methods with parameters.
    The first is resolved in JSTL1.1, with the use of the function taglib. However you can only use that if you have a JSP2.0 container (eg Tomcat 5)
    It would be the following EL expression:
    ${fn:length(frcGatewaySrsBean.frcGatewaySrsDtos)}
    In JSTL1.0, there is no equivalent to get the length of an array.
    Problem 2:
    The for loop would replaced with a c:forEach loop. That eliminates the problem with retrieving element i of the array.
    However JSTL does not support calling methods with parameters. You can only do getter/setters.
    The question - what is the point of FrcGatewaySrsBean.getLong( ... )?
    What does frcGatewaySrsBean.getFrcGatewaySrsDtos().getFrcGatewaySrsId() return that it needs to be passed through the getLong() method?
    Translation without the getLong() method:
    <c:forEach var="frcGatewayDrsDto" items="${frcGatewaySrsBean.frcGatewaySrsDtos}">
      <c:out value="${frcGatewayDrsDto.frcGatewaySrsId}"/>
    </c:forEach>I would probably rename the variables into something a little shorter, but thats just me ;-)
    Hope this helps,
    evnafets

  • JSP/BC4J app: How to get view object row data into a scriplet variable?

    I have a JSP application using BC4J data tags. Within a rowsetiterate tag, how can I get the data value of an attribute for the current row into a scriplet variable?
    Thanks,
    Steve

    Using the <jbo:Row> tag like this:
      <jbo:RowsetIterate .... >
        <%--
         | Establish a scriptable variable "curRow" for the current row
         +-->
        <jbo:Row id="curRow" action="current"/>
        <%
          String foo = (String)curRow.getAttribute("YourAttrName");
        %>

Maybe you are looking for

  • Purchase Order  in SRM Error in process

    Hello , We are using extended classic scenario . SRM 5.0 , ECC 6.0. There is a PO on SRM with status 'Error in Process ' in process .But I checked the line items of the POs. PO has been successfully created and also transfered to ECC for all the line

  • Outer join syntax - oracle 8i

    Here is an Oracle 8i issue I've run into .... I am trying to create a table that contains a record for each hour of the day (even if count is 0). I have a problem when I try a right outer join using the following syntax: SELECT MDT.date_field, COUNT(

  • Using Larger Fonts For Simple Sign

    I am creating a sign.  Using Photoshop CS2 I was very surprised when I tried to create a large character of font size 1500.  Error message noted the maximum was something like 1296. I did not think there was a limit. How do people make huge signs wit

  • Embed links in video

    I would like to embed links to other website locations within the video.  If this is possible, how can I do it? The scenario is that when a person is watching a particular video, links would appear on the screen that would take them to more specific

  • Restoring function to Mighty Mouse

    I once found a post here to temporarily restore vertical scrolling function to a Mighty Mouse by cleaning the scroll ball with a paper towel moistened with rubbing alcohol. That worked for a while, but after 6 month of just working, it went to needin