JSP declaration Tag

Dear All,
Is it ok to use JSP declaration tag? I have heard if we use the declaration tag then this variable name will be shared by all threads and the particular variable will be overridden. Is it true? please advise me on this? can we use this tag in our Jsp files.
Thanking you in advance.
Regards,
Venkat

Yes, it is true that the scope of variable in decalaration tag becomes global. It is as good as declaring a public variable in core java context.
In my opinion one should avoid using the declaration tag.
As there should be less and less public variable in core java class. Every variable should be private to the class and accessing the variable should be only through the instance of the class.

Similar Messages

  • Using JSP declaration tags and expression tags

    I am trying to use JSP without embedding any business logic into my view pages.
    I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?
    And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.
    Thanks

    PaulOckleford wrote:
    I am trying to use JSP without embedding any business logic into my view pages.
    I know that its not good practice to use scriptlets in pages, but is it ok to declare variables and then reference them with expression tags?You can use the JSTL <c:set> for that. But I would still prefer the Servlet above that.
    And on another note does anybody have any links to any decent jsp tutorials (I am not asking for a link to google here, or a link to a google search), by decent I mean tutorials that are not outdated and use scriptlet tags as I am trying to egt away from this.You can find here at least one: [http://balusc.blogspot.com/2008/07/dao-tutorial-use-in-jspservlet.html].

  • JSP declarattion tag

    hi all
    I am confused on this one; please help.
    In a JSP declaration tag , the variables that we declare become class's private vars upon compilation. Similarly, when we declare methods in a declaration tag they become private methods of the compiled class. Now, I wud like to know whether those vars can be accessed inthe methods???

    They can be accessed in the methods, but you should restrain yourself from doing so.
    <%!
      int i = 100; 
      String name = "Bob";
      public int nextInt(){
        return i++;
      public void setName(String name){
        this.name = name;
    %>The issue here is that variables declared in this manner are shared by all users of that jsp page - ie its an instance attribute of the class. Because only one instance of a servlet/jsp is created to service all requests, this attribute is shared.
    The best approach is to declare variables only within your methods, and between <% %> tags.
    If you need to access the variables in your methods (such as setName) pass the parameters up to them.
    Cheers,
    evnafets

  • Calling an inner class in a jsp:usebean tag

    Hi everybody !
    Here's my problem : working in my project on multiple pages, I'm using inner classes/beans to limitate my '.java' files but I'm stuck when calling that 'inner-bean' in my jsp:usebean tag.
    First, I tried to declare in the class parameter : 'class="MyPrincipalBean.theInnerBean" but jsp returns me a 'not found' message.
    I tried an other issue with this :
    'class="MyPrincipalBean$theInnerBean" but I encountered a 'Attempt to use a bean type without a void constructor in jsp:useBean tag (JSP 1.1 specification, 2.13.1)'. Since I can't find that specification, I'm sending an SOS.
    Am I on the good way ? If somebody as encoutered that sort of problem, it would be very kind of you to help me.
    Thanks for your help !
    [email protected]

    Thanks for your help!
    I must recognize that my explainations weren't really precise.
    My principal bean owns a table of my inner-class type :
    public class FirstBean extends EntityBean {
    private SecondBean[] tabSB;
    public SecondBean[] getTabSB() {...}
    public void setTabSB(SecondBean[] p_tabSB) {...}
    public class SecondBean {...}
    So I can call a specific bean from the tab in my Servlet for another page.
    But I think I have the solution and I need your advise :
    I tried this :
    <jsp:useBean id="FirstBean" class="<...>.FirstBean" scope="session" />
    <jsp:useBean id="SecBean" beanName="<...>.FirstBean$SecondBean" type="<...>.FirstBean$SecondBean" scope="request" />
    And would you believe it ? It seems to work ! But I have to test this farther to be sure. What do you think of it ?

  • Jsp:useBean and definition of bean inside jsp:declaration

    I use the following code where I define a bean in jsp:declaration
    Its name is localBean. the problem is that jsp:useBean causes
    a crash and my page is not working without understanding why.
    When I replace the localBean in the jsp:useBean with another Bean
    which is an actual class that resides in the system I have not a problem.
    Any suggestions???
    <HTML>
         <jsp:declaration>          
              static public class localBean {
                   private String value;
                   public String getValue() {
                        return value;
                   public void setValue(String value) {
                        this.value = value;
         </jsp:declaration>
         <jsp:useBean id="localBean" scope="page" class="localBean">
              <jsp:setProperty name="localBean" property="value" value="World"/>
         </jsp:useBean>
         <%-- Whatever HTTP parameters we have, try to set
              an analogous bean property -- %>          
         <jsp:setProperty name="localBean" property="*"/>
         <head>
              <title>Hello World JavaBean</title>
         </head>
         <body>
              <center>
                   <p><h1>
                        Hello
                        <jsp:getProperty name="localBean" property="value"/>
                   </h1></p>
                   <form method="post">
                        Enter a name to be greeted:
                        <input type="text" size="32" name="value"
                        value="<jsp:getProperty name='localBean' property='value'/>">
                        <br>
                        <input type="submit" value="submit"/>
                   </form>
              </center>
         </body>
    </html>          

    Thanks,
    I have added scope="application". It still show "null" indicating that the bean is not initialized with the properties. I would like a quicker way to initialize a bean property than invoking the setProperty tag for each property.
    Here is a simple example that demonstrates the problem:
    <%@ page language="java" %>
    <%@ page import="com.tests.*" %>
    <jsp:useBean id="monBean" class="com.tests.MonBean" scope="application"/>
    <%
    MonBean mb = new MonBean();
    mb.setName("toto");
    monBean= mb;
    %>
    <html>
    <head>
    <title>Lomboz JSP</title>
    </head>
    <body bgcolor="#FFFFFF">
    <jsp:getProperty name="monBean" property="name"/>
    </body>
    </html>And the bean
    package com.tests;
    public class MonBean {
    private String name;
    public String getName() {
         return name;
    public void setName(String name) {
         this.name = name;
    }This show "null".
    Any other idea why this is not working?
    Thanks,
    Julien

  • JSP Userbean tag

    hi everyone,
    I am fairly new to JSP and I am trying to understand some of the basics of JSP, so I am wondering if anyone can tell me if the JSP usebean tag case sensitive, for example I have this, which works perfectly fine:
    For JSP page:
    <%@ page language="java" import="simple.simplebean" %>
    <jsp:useBean id="sample" class="simple.simplebean" scope="page">
    </jsp:useBean>
    <html>
    <body>
    <jsp:setProperty name="sample" property="sample" value="IT Works!" />
    <jsp:getProperty name="sample" property="sample" />
    Hope this works and it does work
    </body>
    </html>
    For JavaBean:
    package simple;
    import java.io.*;
    public class simplebean implements Serializable
         private String Sample;
         public simplebean(){}
         public void setSample(String s) {Sample=s;}
         public String getSample() {return Sample;}
    But, if I have this:
    <jsp:setProperty name="sample" property="Sample" value="IT Works!" />
    <jsp:getProperty name="sample" property="Sample" />
    It won't work because "S" is capital for the property attribute "Sample", which is really strange, so I am wondering what is the limitation in the usage of <jsp:setProperty> and <jsp:getProperty> tag?
    I am can I do this?:
    <jsp:setProperty name="sample" property="setSample" value="IT Works!" />
    <jsp:getProperty name="sample" property="getSample" />
    The setSample and getSample method name.

    Whenever you declare a variable, industry standard says that the variable name should begin with a lowecase letter. Hence
    private String Sample;
    should be declared as:
    private String sample;
    If you have a variable name with more that two words then the first letter of the first word should be lower case and the 2nd word should be uppercase. For example:
    private String mySample;
    The industry standard also says that if you are creating a class then the first letter of every word should be capitalized. Hence, when you declare a class it should be as follows:
    public class SimpleBean{}
    Not:
    public class simplebean{}
    The reason the industry standard is done this way is to make it easy to distinguish between classes and variables and it makes it easier to read variable and class names.
    Imagine trying to read a variable name like this:
    private String thisismypersonalvar;
    as opposed to this:
    private String thisIsMyPerasonalVar;
    The latter is easier to read. The same applies for classes.
    Also, when the first letter of a variable name is lowecase then everyone knows that it is a variable and not a class. Likewise when a classname is capitalized everyone knows that it is a class.
    For example:
    String myString = "this is a string";
    I know that String is a class because the first letter is capitalized and I know that myString is a variable name because the first letter is lowercase.
    It may seem silly but when you are debugging over 500 lines of code then it makes it much easier to understand which name is a class and which one is a variable name.
    After all that being said.
    if you were to use
    <jsp:setProperty name="sample" property="setSample" value="IT Works!" />
    <jsp:getProperty name="sample" property="getSample" />
    this would not work because the name of the property in the Bean is "Sample".
    if this code did not work
    <jsp:setProperty name="sample" property="Sample" value="IT Works!" />
    <jsp:getProperty name="sample" property="Sample" />
    then I would assume that the jsp specification automatically assumed that all the bean property names would begin with a lowercase letter, therefore, it expects the bean property name to be lowercase when it is passed as a parameter to the property attribute.
    For example, the following code you wrote is correct:
    <jsp:setProperty name="sample" property="sample" value="IT Works!" />
    <jsp:getProperty name="sample" property="sample" />
    If your bean property was
    private String mySample;
    then the signatures of the get and set method would be:
    public void setMySample(String a);
    public String getMySample();
    The get and set property in the JSP page would be:
    <jsp:setProperty name="sample" property="mySample" value="IT Works!" />
    <jsp:getProperty name="sample" property="mySample" />
    I hope this helps.
    logikalone

  • Need help with the jsp:useBean tag

    Dear Fellow Java/JSP developers:
    I am trying to use the <jsp:useBean> tag in a jsp that displays the values from a javaBean that gets populated by another class.
    <%@ page contentType="text/html" pageEncoding="UTF-8"%>
    <%@ page import = "java.util.ArrayList"%>
    <%@ page import = "java.util.Iterator"%>
    <%@ page import = "salattimes.CalendarParse" %>
    <%@ page import = "salattimes.Salat" %>
    <!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=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <jsp:useBean id="test" scope="session" class="calendar.Time" />
            <% CalendarParse sTime = new CalendarParse();
                Time mytime = sTime.runExample();%>
            <%=mytime.getA() %>
            <%=mytime.getB() %>
            <%=mytime.getC() %>
            <%=mytime.getD() %>
            <%=mytime.getE() %>
        </body>
    </html>However, up to now, I am only able to display the values on my JSP page using the scriptlet
    <% CalendarParse sTime = new CalendarParse();
                Time mytime = sTime.runExample();%> to declare and create the object (the method call sTime.runExample(); populates the fields in the Java Bean), and the expressions:
    <%=mytime.getA() %>
             <%=mytime.getB() %>
             <%=mytime.getC() %>
             <%=mytime.getD() %>
             <%=mytime.getE() %>to present the values on the screen. What I would like to do is assign the object that I create to a javaBean reference declared in a <jsp:useBean> tag as follows:
    <jsp:useBean id="test" scope="session" class="calendar.Time" />
            <% CalendarParse sTime = new CalendarParse();
                test = sTime.runExample();%>and then present the values stored in the bean to the JSP page as follows:
    <jsp:getProperty name="test" property="a" />
            <jsp:getProperty name="test" property="b" />
            <jsp:getProperty name="test" property="c" />
            <jsp:getProperty name="test" property="d" />
            <jsp:getProperty name="test" property="e" />
            <jsp:getProperty name="test" property="f" />Is this possible? When I try the above, I get "null" as my output on the screen. When I try the first approach listed above, I get the values I am looking for. Is there a way to accomplish this using the <jsp:useBean> approach?
    Thanks to all those who reply.
    Sincerely;
    Fayyaz

    The code:
    <jsp:useBean id="calendar" class="calendar.CalendarParse" scope="session"/>
    <c:set var="time" value="${calendar.time}"/>Would be roughly equivalant to:
    calendar.CalendarParse calendar = new calendar.CalendarParse();
    Object time = calendar.getTime();I assumed that the CalendarParse object was in the calendar package because that was were your Time class was (when you used <jsp:useBean id="test" scope="session" class="calendar.Time" />"), but when I look back at your original post I see I was wrong and the use of calendar as both the incorrect package and the variable name was confusing. To make the code more similar to your original post the code should have read:
    <jsp:useBean id="sTime" class="salattimes.CalendarParse"/>
    <c:set var="myTime" value="${sTime.time}" scope="session"/>
    ${myTime.a}
    ${myTime.b}
    ${myTime.c}
    etc...Here is an explanation of the parts:
             /* name of the variable */  /* fully qualified class name, package.className */
    <jsp:useBean id="sTime"           class="salattimes.CalendarParse"/>
      /* name of the new object from bean */  /* source of object, variable.property */    /* Scope of new object */
    <c:set var="myTime"              value="${sTime.time}"             scope="session"/>
    /* data to display variable.property */
    ${myTime.a}Where a 'property' in a bean is defined as a method in the form of getProperty(). So the 'time' property is getTime() and the 'a' property is getA().

  • Connection Pooling and JSP Custom Tag Library - is code (inside) the best way/correc?

    Hi, can anyone advise as to whether my tag library code (based
    on Apache Jakarta Project) will actually achieve connection
    pooling functionality across my entire JSP based application? I
    am slightly concerned that my OracleConnectionCacheImpl object
    may exist multiple times, hence rendering my conection pooling
    attempt useless.
    package com.solved.tag.dbtags.connection;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    import javax.servlet.jsp.JspTagException;
    import javax.sql.DataSource;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import oracle.jdbc.pool.OracleConnectionCacheImpl;
    * <p>JSP tag connection, used to get a
    * java.sql.Connection object.</p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>connection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.ConnectionTag&lt;/t
    agclass>
    * &lt;bodycontent>JSP&lt;/bodycontent>
    &lt;teiclass>com.solved.tag.dbtags.connection.ConnectionTEI&lt;/t
    eiclass>
    * &lt;info>Opens a connection based on a jndiName.&lt;/info>
    * &lt;attribute>
    * &lt;name>id&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    public class ConnectionTag extends TagSupport {
    static private OracleConnectionCacheImpl cache = null;
    public int doStartTag() throws JspTagException {
    try {
    Connection conn = null;
    if (cache == null) {
    try {
    InitialContext ic = new InitialContext();
    DataSource ds = (DataSource) ic.lookup
    ("jdbc/pool/OracleCache");
    cache = (OracleConnectionCacheImpl)ds;
    catch (NamingException ne) {
    throw new JspTagException(ne.toString());
    conn = cache.getConnection();
    pageContext.setAttribute(getId(),conn);
    catch (SQLException e) {
    throw new JspTagException(e.toString());
    return EVAL_BODY_INCLUDE;
    package com.solved.tag.dbtags.connection;
    import java.sql.Connection;
    import java.sql.SQLException;
    import javax.servlet.jsp.tagext.TagSupport;
    * <p>JSP tag closeconnection, used to close the
    * specified java.sql.Connection.<p>
    * <p>JSP Tag Lib Descriptor
    * <pre>
    * &lt;name>closeConnection&lt;/name>
    &lt;tagclass>com.solved.tag.dbtags.connection.CloseConnectionTag&
    lt;/tagclass>
    * &lt;bodycontent>empty&lt;/bodycontent>
    * &lt;info>Close the specified connection. The "conn"
    attribute is the name of a
    * connection object in the page context.&lt;/info>
    * &lt;attribute>
    * &lt;name>conn&lt;/name>
    * &lt;required>true&lt;/required>
    * &lt;rtexprvalue>false&lt;/rtexprvalue>
    * &lt;/attribute>
    * </pre>
    * @author Matt Shannon
    * @see ConnectionTag
    public class CloseConnectionTag extends TagSupport {
    private String _connId = null;
    * The "conn" attribute is the name of a
    * page context object containing a
    * java.sql.Connection.
    * @param connectionId
    * attribute name of the java.sql.Connection to
    close.
    * @see ConnectionTag
    public void setConn(String connectionId) {
    _connId = connectionId;
    public int doStartTag() {
    try {
    Connection conn = (Connection)pageContext.getAttribute
    (_connId);
    conn.close();
    } catch (SQLException e) {
    // failing to close a connection is not fatal
    e.printStackTrace();
    return EVAL_BODY_INCLUDE;
    public void release() {
    _connId = null;
    package com.solved.tag.dbtags.connection;
    import javax.servlet.jsp.tagext.TagData;
    import javax.servlet.jsp.tagext.TagExtraInfo;
    import javax.servlet.jsp.tagext.VariableInfo;
    * TagExtraInfo for the connection tag. This
    * TagExtraInfo specifies that the ConnectionTag
    * assigns a java.sql.Connection object to the
    * "id" attribute at the end tag.
    * @author Matt Shannon
    * @see ConnectionTag
    public class ConnectionTEI extends TagExtraInfo {
    public final VariableInfo[] getVariableInfo(TagData data)
    return new VariableInfo[]
    new VariableInfo(
    data.getAttributeString("id"),
    "java.sql.Connection",
    true,
    VariableInfo.AT_END
    data-sources.xml:
    <?xml version="1.0"?>
    <!DOCTYPE data-sources PUBLIC "Orion data-
    sources" "http://xmlns.oracle.com/ias/dtds/data-sources.dtd">
    <data-sources>
    <data-source
    class="oracle.jdbc.pool.OracleConnectionCacheImpl"
    name="jdbc/pool/OracleCache"
    location="jdbc/pool/OracleCache"
    url="jdbc:oracle:thin:@oracle1:1521:pdev"
    >
    <property name="maxLimit" value="15" />
    <property name="cacheScheme" value="2" />
    <property name="user" value="console" />
    <property name="password" value="console" />
    <description>
    This DataSource is using an Oracle-native DataSource Class so as
    to allow Oracle Specific extensions.
    A getConnection() call on this DataSource will return
    oracle.jdbc.driver.OracleConnection.
    The connection returned is a logical connection.
    The caching scheme in place is Fixed Wait. Refer below to
    possible values.
    Dynamic 1
    Fixed Wait 2
    Fixed Return Null 3
    </description>
    </data-source>
    </data-sources>
    many thanks,
    Matt.

    Hi. Show me your pool definition.
    Joe
    Ramamurthy wrote:
    I am using the jsp custom tag library from BEA called sqltags.tld which came with Weblogic 5.1. Currently I am using Weblogic6.1 sp2 on Solaris.
    I have created a Connection Pool for Sybase database using the driver com.sybase.jdbc.SybDriver.
    When I created jsp page to connect to the connection pool using sqltags custom tag library, I am getting the error
    "javax.servlet.jsp.JspException: Failed to write body content
    at weblogic.taglib.sql.ConnectionTag.doAfterBody(ConnectionTag.java:43)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:1014)"
    After this message, whenever I try to access the same jsp page I am getting the message
    "javax.servlet.jsp.JspException: Failed to load JDBC driver: weblogic.jdbc.pool.D
    river
    at weblogic.taglib.sql.ConnectionTag.doStartTag(ConnectionTag.java:34)
    at jsp_servlet.__hubwcdata._jspService(__sampletest.java:205)".
    Can you please help me the reason why this problem is happening and how to fix this ?
    This problem doexn't happen consistently. This occurs once in a while.
    I tried to increase Login delay Seconds parameter in the Connection Pool to 15 sec. It didn't help me much.
    Thanks for your help !!!
    Ram

  • How to use JSP custom tag lib in PAR file?

    Hi All,
    I am trying to customize mastheaderpar file. For that I have downloaded relevant par file and making the changes accordingly.
    As part of the changes I would require to use JSP custom tag library in my par file.
    I have the TLD file and relevant classes in the jar file. I would like to know where and what kind of modifications have to be done to use the jsp custom tag library.
    I tried modifying some things in portalapp.xml but was not successful.
    Please help me on how to proceed with this? It would be great if you can provide the xml entry to use this tag library
    Thanks
    Santhosh

    Hi Johny,
    Thanks for the reply. Actually I am able to change colors etc. with out any problem.
    My requirement is to use XMLTaglib in mastheader par file. This tag lib is from apache tomcat. I have the relevant TLD and class files. I copied TLD file into taglib dir of portal-inf and class file in src api.
    And I have added the following line in portalapp.xml under component-profile section of default
    <property name="tlxtag" value="/SERVICE/Newmastheader/taglib/taglibs-xtags.tld">
    Is this the right way to use tag lib? Actually before adding this line I used to get the error saying "Error parsing taglib", but now the error does not occur and I am getting new error. This is an exception in one of the taglib classes.
    Could any one provide me some inputs on how to check this error?
    Thanks
    Santhosh

  • Data Streaming in JSP custom tag

    We have a JSP custom tag which uses a StringBuffer object to store the HTML content. In the doEndTag method, we use the JSPWriter's print method to send the buffer's content to the browser.
    Now, there are cases when the HTML content becomes very large,in the order of 1 - 10MB. In such cases, is there a way we can start streaming the data from the custom tag as the buffer is being built, rather than waiting for the entire buffer to be written out in the doEndTag.

    Yeah, just call the JSPWriter's print method instead of using the StringBuffer, or write your own subclass of StringBuffer (or StringBuilder if Java 5+) which will do this for you automatically when the size is at a certain point, and clear it out)

  • Can I write Design-time for JSP custom tag(not JSF components)

    I have some old JSP custom tags(not JSF components), and I want to use them in the IDE through the toolbox.
    Now I have already written the BeanInfos for these tags, and they can be drag from the toolbox; but it will throw a Exception when render the tags, and the properties in the Property Editor are not which I describe in the BeanInfos.
    How can I write Design-time for these tags? or whether it is possible to write the Design-time for these tags?
    the Exception is shown as follow:
    java.lang.ClassCastException
         at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1347)
    [catch] at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1086)
         at com.sun.rave.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:993)
         at com.sun.rave.css2.FacesSupport.getFacesHtml(FacesSupport.java:152)
         at com.sun.rave.css2.CssContainerBox.addNode(CssContainerBox.java:373)
         at com.sun.rave.css2.CssContainerBox.createChildren(CssContainerBox.java:354)
         at com.sun.rave.css2.DocumentBox.createChildren(DocumentBox.java:90)
         at com.sun.rave.css2.DocumentBox.relayout(DocumentBox.java:160)
         at com.sun.rave.css2.PageBox.layout(PageBox.java:392)
         at com.sun.rave.css2.PageBox.relayout(PageBox.java:454)
         at com.sun.rave.css2.DocumentBox.redoLayout(DocumentBox.java:313)
         at com.sun.rave.css2.PageBox.redoLayout(PageBox.java:460)
         at com.sun.rave.css2.DocumentBox.changed(DocumentBox.java:634)
         at com.sun.rave.designer.DesignerPaneUI$UpdateHandler.changedUpdate(DesignerPaneUI.java:1012)
         at com.sun.rave.text.Document.fireChangedUpdate(Document.java:851)
         at com.sun.rave.text.Document$5.run(Document.java:631)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

    I have some old JSP custom tags(not JSF components), and I want to use them in the IDE through the toolbox.
    Now I have already written the BeanInfos for these tags, and they can be drag from the toolbox; but it will throw a Exception when render the tags, and the properties in the Property Editor are not which I describe in the BeanInfos.
    How can I write Design-time for these tags? or whether it is possible to write the Design-time for these tags?
    the Exception is shown as follow:
    java.lang.ClassCastException
         at com.sun.rave.insync.faces.FacesPageUnit.renderNode(FacesPageUnit.java:1347)
    [catch] at com.sun.rave.insync.faces.FacesPageUnit.renderBean(FacesPageUnit.java:1086)
         at com.sun.rave.insync.faces.FacesPageUnit.getFacesRenderTree(FacesPageUnit.java:993)
         at com.sun.rave.css2.FacesSupport.getFacesHtml(FacesSupport.java:152)
         at com.sun.rave.css2.CssContainerBox.addNode(CssContainerBox.java:373)
         at com.sun.rave.css2.CssContainerBox.createChildren(CssContainerBox.java:354)
         at com.sun.rave.css2.DocumentBox.createChildren(DocumentBox.java:90)
         at com.sun.rave.css2.DocumentBox.relayout(DocumentBox.java:160)
         at com.sun.rave.css2.PageBox.layout(PageBox.java:392)
         at com.sun.rave.css2.PageBox.relayout(PageBox.java:454)
         at com.sun.rave.css2.DocumentBox.redoLayout(DocumentBox.java:313)
         at com.sun.rave.css2.PageBox.redoLayout(PageBox.java:460)
         at com.sun.rave.css2.DocumentBox.changed(DocumentBox.java:634)
         at com.sun.rave.designer.DesignerPaneUI$UpdateHandler.changedUpdate(DesignerPaneUI.java:1012)
         at com.sun.rave.text.Document.fireChangedUpdate(Document.java:851)
         at com.sun.rave.text.Document$5.run(Document.java:631)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

  • Using variables in a jsp:useBean tag

    I was wondeing if it is possible in any way to use variables in a jsp:useBean tag. Here is an example of what I am trying to do.
    <%
    String beanType = request.getParameter( "bean" );
    if( beanType.equals( "Bean1" ) ) {
    beanClass = "com.myCompany.Bean1";
    } else {
    beanClass = "com.myCompany.Bean2";
    %>
    <jsp:useBean name="<%= beanType %>" class="<%= beanClass %>"/>
    I also tried using this approach
    <%
    if( beanType.equals( "Bean1" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean1"/>
    <%
    } else if( beanType.equals( "Bean2" ) ) {
    %>
    <jsp:useBean id="bean" class="com.myCompany.Bean2"/>
    <%
    %>
    Neither approach seems to work. Is there any way around this problem?
    Thanks,
    Marcus.

    Hi,
    check:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=398998&tstart=75&trange=15

  • How can i load A gui JTable bean through jsp:useBean tag in a jsp page

    Hi,
    i am chiranjit , i am in a jsp project . i am desparately looking a solution for below stated problem:
    i want to make a jsp page for master entry , that why i want to load a GUI Java bean in my jsp page.This GUI Bean contaning a JTable in which allow grid type data entry in the jsp page. But i am unable load that bean in the jsp page through jsp:useBean tag in my page.So if you have any solution then send in the forum as early as possible.
    Thank you
    chiranjit

    No can do. JSPs can only output plain HTML (and javascript...) They are not used like normal Java classes.
    If you need a complex GUI then you might use an Applet instead. If you want to use a JSP then you are stuck using normal HTML components, like <table> <form...> <input type="text"> etc...

  • Problem with flush=true in the jsp:include tag

    Hello
    I have deployed a JSP based application , based on the apache struts framework. The web server is Sun One Webserver 6 Service Pack4, on a windows 2000 machine
    The same application was tried on SunONE application server 7, and it works without any problem. However in this case the following error , on the page
    javax:servlet.jspexception:Illegal to flush within a custom tag
    Does this mean flush="true" is not allowed within custom tags
    Or is there a workaround for this
    Any help is appreciated
    thanks
    - Aniruddha

    Hi,
    This is a known problem, ��flush before you include�� limitation in JSP 1.1.
    As a result, you have to state flush="true" every time you include a jsp using <jsp:include> tag if you are using JSP1.1.
    Fortunately, it is fixed in JSP1.2. The flush attribute controls flushing. If true, then, if the page output is buffered and the flush attribute is given a ��true�� value, then the buffer is flushed prior to the inclusion, otherwise the buffer is not flushed. The default value for the flush attribute is ��false��.
    Gary Wang
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Jsp:declaration and request

    Can we use request in jsp:declaration?
    In my program request cannot be recognised unless it
    is inside of <jsp:scriptlet>
    So what do we set inside of jsp:declaration?

    The code that you put inside the jsp:scriptlet is inside a method called _jspService(request, response).  The request method is local to the service method.
    To get it into the declared method you have to pass it as a parameter to the method:
      String getName(HttpServletRequest request) {
        String str = (String)request.getAttribute("name");
        return str;
      }and then call it like:
      String name = getName(request); That being said, you should do whatever you can to remove the whole method declarations from the JSP you can. You can do what you have above by using JSTL and EL:
        ${request.name}No method declarations, no passing request around, nice clean code. Look up JSTL and EL (Expression Language).

Maybe you are looking for