Jsp+scriplet

Am using jsp and display tag.
Version am using is:
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:display="urn:jsptld:http://displaytag.sf.net/el" xmlns:c="urn:jsptld:http://java.sun.com/jstl/core">
Here am using displaytag to display table. Am using C:forEach to iterate through each column and display it. Using c:out for displaying it along with checkbox. Till here everything works fine.
But when i try to use Scriplet am getting error.
Error:
could no process the requestorg.apache.jasper.JasperException: /web/viewdata.jsp(19,2) The content of elements must consist of well-formed character data or markup.
Can anyone help me.. Thanks in advance

HEY THANKS.. HERE IS THE CODE..
I tried use jsp:scriplet but yet there is an error..
Error is:
could no process the requestorg.apache.jasper.JasperException: /web/viewdata.jsp(19,15) Invalid standard action: scriplet
<jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:display="urn:jsptld:http://displaytag.sf.net/el" xmlns:c="urn:jsptld:http://java.sun.com/jstl/core">
<jsp:directive.page contentType="text/html; charset=UTF-8" />
<html>
          <link rel="stylesheet" href="../css/displaytag.css" type="text/css" />
     <link rel="stylesheet" href="../css/maven-base.css" type="text/css" />
          <link rel="stylesheet" href="../css/maven-theme.css" type="text/css" />
          <link rel="stylesheet" href="../css/site.css" type="text/css" />
          <link rel="stylesheet" href="../css/screen.css" type="text/css" />
          <head>
          </head>
          <body>
          <c:forEach var="obj" items="${col}">
               <tr>
               <td>     <input type="checkbox" name="initCheckBoxMulti" value="${obj.property}" class="button"/> <c:out value= "${obj.property}" />
               </td>
               <td></td>
               </tr>
          </c:forEach>               
     <display:table name="sessionScope.results.rows" class="reportviewer" export="true" id="row" defaultsort="1" defaultorder="ascending"
pagesize="40" cellspacing="0" decorator="org.displaytag.decorator.TotalTableDecorator" >
          <display:setProperty name="paging.banner.placement" value="top" />
     <c:forEach var="obj" items="${col}">
               <c:choose>
          <c:when test='${obj.property== "Banner"}'>
                    <display:column property="${obj.property}" sortable="true" group="1"/>
                    </c:when>
          <c:when test='${obj.property== "Campaign"}'>
                    <display:column property="${obj.property}" sortable="true" group="1"/>
                    </c:when>          
          <c:when test='${obj.property== "Advertiser"}'>
                    <display:column property="${obj.property}" sortable="true" group="1"/>
                    </c:when>                              
                    <c:otherwise>
                         <display:column property="${obj.property}" sortable="true"/>
               </c:otherwise>
                    <c:otherwise>
                         <display:column property="${obj.property}" sortable="true"/>
               </c:otherwise>
                    <c:otherwise>
                         <display:column property="${obj.property}" sortable="true"/>
               </c:otherwise>                              
               </c:choose>
     </c:forEach>
          </display:table>
     </body>
</html>
</jsp:root>

Similar Messages

  • I need JSP SCRIPLET report help!

    Here's what we are doing.
    We are using a JSP report built in report builder (10gR2,win xp pro), and modifying the layout in the web builder part of the tool that generates the JSP.
    These reports that are run, end up being exported to EXCEL via the MS Windows export function in Internet Explorer.
    I have managed to write the code I need into a Javascript - which works great - EXCEPT when we export to EXCEL, the MS process does not run JavaScript - so we do not get what is on the screen. So I need this code converted to a JSP scriplet, so it will work when exported to excel.
    here is the javascript I came up with. Basically it says if the string length of the HTML code generated from the reports tag is > 51, then give me that same html inside of a <tr> <td> </td> </tr>, else do nothing (do not produce a table row).
    <script type = "text/javascript" language="JavaScript">
    if ( '<td <rw:id id="HFpltitlesname87" breakLevel="RGpltitlecode871" asArray="no"/> class="OraRowHeader"> <rw:field id="Fpltitlesname87" src="pl_title_sname" breakLevel="RGpltitlecode871" breakValue="" nullValue=""> F_pl_title_sname </rw:field> </td> '.length > 51 )
    document.writeln ( '<tr>');
    document.writeln ('<td <rw:id id="HFpltitlesname87" breakLevel="RGpltitlecode871" asArray="no"/> class="OraRowHeader"> <rw:field id="Fpltitlesname87" src="pl_title_sname" breakLevel="RGpltitlecode871" breakValue="" nullValue=""> F_pl_title_sname </rw:field> </td> ' );
    document.writeln ( '</tr>' );
    </script>
    During JSP compile time, the <rw:id tag gets translated to the value as expected. I need to come up with something at compile time via a scriplet - so it will be pure HTML and will import into EXCEL.
    This is cross posted in Reports.

    I found a solution.
    No JavaScript or scriplets needed.
    I moved the report tag to act like a Group Above layout vs a Group Left.
    We had chosen Group Left in the layout since it was the lesser of 2 evils for out column headers.

  • 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.

  • I want to execute JSP scriplet in onClick function of the button HTML page

    in my JSP page, the code is like this...
    <input type="button" value="xyz" onClick="<% my jsp code%>">
    the jsp code is executing wen the page is loading..
    i want the jsp code is executed wen v click the button..
    can i write like this...if not how should i write.
    plz suggest me...
    Thanking you
    Sorry if i post this in a wrong forum....
    Edited by: Murthy_Srinivas on Jun 5, 2008 10:49 PM

    the jsp code is executing wen the page is loading..
    i want the jsp code is executed wen v click the button..Not possible(in the way you are trying to achieve). JSP codes are processed in the server and only processed data/results are sent to browser which you see in your screen. Browser cannot/willnot execute the jsp code.
    ...if not how should i write.The only way is to make a server call(eg: either submit a form, make a http request using Ajax etc)

  • Problem accesing JPA EntityManager from JSP scriplet

    Hy,
    I am trying to access an EntityManager from JSP scriptlet for testing purposes and it just doesn't work.
    Here is the JSP scriptlet:
    <%
    EntityManager em = (EntityManager) (new InitialContext()).lookup("java:comp/env/persistence/em");
    Query query = em.createQuery("select u from USER u");
    List<User> users = (List<User>) query.getResultList();
    for (User user : users) { user.toString(); }
    %>
    The application is deployed in JBoss 4.2.2.GA.

    Sorry for my previous post. It was incomplete.
    I am trying to access an EntityManager from JSP scriptlet for testing purposes and it doesn't work.
    Here is the JSP scriptlet:
    <%
    EntityManager em = (EntityManager) (new InitialContext()).lookup("java:comp/env/persistence/em");
    Query query = em.createQuery("select u from USER u");
    List<User> users = (List<User>) query.getResultList();
    for (User user : users) { user.toString(); }
    %>
    persistence.xml file :
    <persistence-unit name="myApp">
              <provider>org.hibernate.ejb.HibernatePersistence</provider>
              <jta-data-source>java:/XAOracleDS</jta-data-source>
    <properties>
    <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9iDialect"/>
    </properties>
    </persistence-unit>
    web.xml file :
    <persistence-context-ref>
              <persistence-context-ref-name>persistence/em</persistence-context-ref-name>
              <persistence-unit-name>myApp</persistence-unit-name>
         </persistence-context-ref>
    The application is deployed in JBoss 4.2.2.GA. When I access the JSP page I get the following exception:
    javax.servlet.ServletException: javax.naming.NameNotFoundException: persistence not bound
    I guess I have to configure the resource in jboss-web.xml too, but I don't know how. I tried with <resource-ref>, but I got the same error.
    Any help at all would be highly appreciated !
    Thanks.
    Andrei

  • Passing values to JavaBean function using jsp scriplet

    Hi,
    I have a JavaBean funtion that is SaveData(parameters)
    which save the values from HTML form.
    Now i want a code for pass the values from HTML form to SaveData() function using jsp scriptlet.
    I used the code
    <jsp:useBean id="JDBC" class="bean.JDBCBean" scope="application"></jsp:useBean>
    <%=JDBC.saveData(phonenumber,manufacturer,model,email,country,newsletter)%>
    Here
    JDBCBean -> Bean Name
    phonenumber,manufacturer,model,email,country,newsletter ->HTML form's text values
    But it didnt work properly.
    Anyone help me to correct this.

    Hi,
    i have the same code like above
    I have to pass the parameters with form name under the following code.
    <jsp:useBean id="JDBC" class="bean.JDBCBean" scope="application"></jsp:useBean>
    <%=JDBC.saveData(registration.phonenumber.value,id_type.value,id_style.value,registration.email.value,registration.scountry.value,player_type.values)%>
    Here
    registration -> HTML form name
    But i got the error for
    package registration does not exist
    out.print(JDBC.saveData(registration.phonenumber.value,id_type.value,id_style.value,registration.email.value,registration.scountry.value,player_type.values));
    How to i correct this?
    Anyone help me......

  • Using JSP scriplets in the JSF tags

    Hi,
    I haven't done that much JSP development using various tag libraries prior to looking at JSF, hence this very basic question:
    I am declaring and manipulating Java variables in my JSP. Is there a way to access those in my JSF tags? It seems that something like:
    <%
    String myString="MyLabel";
    %>
    <h:view>
    <h:outputText id="myID" value="<%=myString%>" />
    </h:view>
    blows up in the JSF processor.
    I am porting some stuff to JSF and hence do not use backing beans in all cases.
    Any suggestions/ideas/pointers are greatly appreciated.
    Thanks in advance,
    Vadim.

    JSF action element attributes take JSF EL expressions, not Java expressions. A JSF EL expression has access to objects in one of request, session or application scope only, not to scripting variables. One way to get your example to work is by putting the String in one of these scopes within the scriptlet, e.g.:
    <%
      String myString="MyLabel";
      request.setAttribute("myString", myString);
    %>
    <h:view>
      <h:outputText id="myID" value="#{myString}" />
    </h:view>But, if you're porting a JSP-based application to JSF, I strongly recommend that you move all scriptlet code into beans; otherwise it's kind of pointless to migrate to JSF. The strength of JSF is its separation of UI layout and application logic.
    Even though JSP happens to be one way to wire up a JSF view with JSF components, JSF has very little to do with JSP. You need to understand the basic JSF component model, event-driven development, and use JavaBeans to really gain any benefits. Don't be fooled into believing that JSF is "just a new JSP tag library" by the support for JSP as the default presentation layer; it's far more than that, and I personally believe that using JSP as the presentation layer makes using JSF a lot harder than it should be. In fact, most of the issues posted in this forum are issues with the JSP layer, not with the core JSF components or the infrastructure classes.
    Hans Bergsten (EG member)

  • Jsp scriplet conditional on javascript

    I discovered something quirky that seems to work and I wanted to know if anyone else has run
    across this.
    I have a jsp page (profile.jsp) that includes a jsp
    ex: <SCRIPT SRC="terminate.jsp"></SCRIPT>
    later in the profile.jsp page I call a function in terminate.jsp
    ex: onClick=killIt();
    The killIt() javascript function is:
    function killIt()
    <% session.invalidate(); %>
    top.close();
    It seems that the session.invalidate only gets execute when the killIt() javascript function gets called.
    Has anyone run across this?
    Is this an acceptable thing to do?

    I think what is happening is that your session is invalidated when the browser goes back to the web server to load terminate,jsp. (because of the SRC attribute in the SCRIPT tag). It has nothing to do with the onclick.

  • Jsp sriplets not working in properly in ojsp

    Hi every one i have this ADF application develped in jdevelper 11.1.1.0.2 and deployed in to weblogic server version 10.3.0 and it worked fine.plese note i have used
    ADF for the presentaion layer.We had to migrate in to weblogic server version 10.3.2.for this i used jdevelper version 11.1.1.2.0 and open the project from this and i click yes for the migration.
    then i have deployed the new war file in to the new server.but the thing is it doesnt work the expected way.for my knowldge the issue is something to do with ojsp.when it tries to read jsp scriplets in the jsp page it throws an error.it is as followes
    **JspServlet error: Servlet unable to dispatch to the following requested page: The following exception occurred:oracle.jsp.parse.JavaCodeException:  Line # 13, oracle.jsp.parse.JspParseTagScriptlet@3f673160***
    **Error: Java code in jsp source files is not allowed in ojsp.next mode.>**
    any solution to this.????can i disable the ojsp compiler and go to normal jsp compliser?if so how to do it?
    thanks in advance every one :)
    Umesh

    Extracted from Note 1067696.1:
    You need to either adapt your code to remove the scriptlets in your JSP page,
    or you can use the following Java option to disable OJSP:
    -Dadfvdt.disableOjspDeployment=true
    You can add this option -Dadfvdt.disableOjspDeployment=true in your file "ide.conf" in the directory "<Middleware_Home>\jdeveloper\ide\bin"
    For your Production environment, you can have your Managed WLS ignoring the OJSP mode by adding the Java Option -Dadfvdt.disableOjspDeployment=true
    * in the "startManagedWebLogic" (if you want to limit it to a specific Managed Server)
    * or "setDomainEnv" (for all managed servers in a domain).

  • Display request contents in JSP page

    i need to display the contents in a request in my JSP.
    meaning:
    i have a hashmap (containing string and a list) coming from the EJB tier to struts action in an event response object, I'm sure that the request has these values. cuz i tested it in struts action using the following code:
    HashMap result = (HashMap)((EventResponseSupport)request.getAttribute(WebKeys.EVENT_RESPONSE)).getPayload();
    System.out.println("Sponsor name = " + result.get("sponsor"));I am able to print it in the console but i need to know how to display it in the jsp. i tried many things but i can't get it right.
    first i need to display the string and then i need to iterate through the list to display its contents in a table.
    any help would be appreciated.

    Kindly use JSP Scriplet to load the HashMap into the Page Context.
    Then you can use the Struts iterate tags to paint the contents of the HashMap

  • How to call Generic Page flow from jsp

    Hi All,
    I have some links in my home page(jsp file).Based on user's selection, i need to show another JSP page using pageflow(JPF).
    thanks in advance
    vandana

    i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks

  • How to call java script function from JSP ?

    how to call java script function from JSP ?

    i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks

  • Using static variables in JSP

    Hi All,
    I have written the following code, but its not compiling saying that "Class or interface declaration expected. static "
    I dotn know whats wrong in this scriplet though.. any help is greatly appretiated.
    <%@ 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>JSP Scriplet</title>
    </head>
    <body>
    <%
    static int counter = 15;
    for(int i = 0; i < 15; i++){
    int p = returnCounter();
    if(p == 0)
    System.out.println("I am the 15th user");
    public static int returnCounter(){
    counter = counter - 1;
    System.out.println("counter : " + counter);
    return counter;
    %>
    </body>
    </html>

    Simply put, you're Java code is wrong.
    The detail is that essentially all of the code in your JSP file is in one big method.
    So, here's what your code looks like to the compiler:
    public void _internalJspDoPageCode() {
        static int counter = 15;
        public static int returnCounter() {
    }You can't simply nest methods like this in Java.
    If you want to, you can try this:
    <%
        public class mycounter {
            static int counter = 15;
            public static int returnCounter() {
                counter = counter - 1;
                return counter;
        for (int i = 0; i < 15; i++) {
            int p = mycounter.returnCounter();
            if(p == 0)
                System.out.println("I am the 15th user");
    %>That will create an inner class with a static member, which is basically what you're trying to do.
    But note that this inner class is only accessible from this JSP page, and no where else.

  • Set jsp variable in javascript

    I have a simple question.
    I have a section in jsp as below
    <%!
    String initial = "true";
    %>
    Can I set the "initial" parameter in javascript function in the same jsp like below?
    function init() {
    <%! initial = "true"; %>
    If not, would you please give me the syntax to do it?
    Thanks in advance,
    Mustafa

    the jsp scriptlet code, everything in between your <% ... %> marks, is compiled on the server.
    the javascript code is run on the client.
    therefore, you can NOT edit the scriptlet code from javascript. it cannot be done.
    you CAN however edit your javascript code with the jsp scriplet. see the below example, which shows me setting a javascript variable based on some scriplet code...
    <% String name = "Joe Schmoe"; %>
    <script>
    function doSomething() {
    var something = '<%= name %>';
    </script>
    When that page is rendered it will look like this...
    <script>
    function doSomething() {
    var something = 'Joe Schmoe';
    </script>

  • Applets in JSP --- I'm going crazy!

    I am using an applet I have written on a JSP page which I have also written.
    Using: Win2K, IE6, J2SDK 1.4, Tomcat 4.0.3
    I have several problems. Even if you can answer only one of them, it will be a great help!
    Here is how I'm adding the applet.
    <jsp:plugin type="applet" code="RawData.class" name="rawData" jreversion="1.4" width="700" height="55" >
    <jsp:fallback>
    Plugin tag OBJECT or EMBED not supported by browser.
    </jsp:fallback>
    </jsp:plugin>
    </TD>
    Problem 1) I can only get the applet loaded if the applet class file is in the same folder as the JSP file. Anything else, and I get a ClassNotFoundException.
    Can't get the CODEBASE to do anything for me at all.
    I set my codebase="/RawData/classes", but makes no difference.
    I then tried Jarring my applet and placing RawData.jar in the same folder with the JSP. But also no go. I then set codebase="RawData.jar", but guess what... Nothing.
    So my questions are: How do I get the applet to load from the applet.class files using codebase if the applet files are in a sub folder? And how do I get my applet to load from a Jar?
    Problem 2) Once this applet is loaded, I have the biggest nightmare imaginable to get the browser to load a new version after I have updated it. And trust me, there is not and old version of the applet.class in my ClassPath. In fact there is not another copy of the applet.class file anywhere on my PC. I made sure. I have also disabled the Java Plugin Cache option, and deleted my temporary internet files with Explorer. But the thing persists in loading the old version from somewhere. What the heck do I do? I fear this is driving me insane.. :)
    Problem 3) I need the HTML components to interact with the applet.
    When I do a call to an applet function passing no parameters it works fine, and I get the value back, like this:
    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub btnGetID1_OnClick
    document.all("id1Pattern").innerText = document.rawData.getSelection()
    End Sub
    -->
    </SCRIPT>
    But when I do a function call, passing parameters, the scrip just stops working altogether, like this.
    <SCRIPT LANGUAGE="VBScript">
    <!--
    Sub id1Pos_onfocus
    document.rawData.setSelection(5, 10)
    End Sub
    -->
    </SCRIPT>
    Why is this. What am I doing wrong.
    And better yet... Is there a way of manipulating the HTML components from within JSP scriplet <% ... %>?
    Please if anyone can help... It will be greatly appreciated. I am at a loss!
    Thanx. Quigrim

    Quigrim wrote:
    Problem 1) I can only get the applet loaded if the applet class file
    is in the same folder as the JSP file. Anything else, and I get a
    ClassNotFoundException. Can't get the CODEBASE to do anything for me
    at all.Set CODEBASE to point to the relative directory where your code is. If it is in the same directory as the JSP then CODEBASE="."; if it is in a sub-directory 'classes' then CODEBASE="classes".
    Problem 2) Once this applet is loaded, I have the biggest nightmare
    imaginable to get the browser to load a new version after I have
    updated it. Close ALL browser windows - you have to force the plugin JVM to re-initialise - I've not found any other way to do it.
    Hope these help you.
    Phil.

Maybe you are looking for