Since you are fetching the String by using pageContext.getAttribute,
you must have set it on the jsp-page with pageContext.setAttribute.

Note that if no scope is specified it implies page scope.

/Steff

-----Original Message-----
From: Andrea Gianni [mailto:[EMAIL PROTECTED]]
Sent: den 5 juli 2001 09:12
To: [EMAIL PROTECTED]
Subject: Re: use JSP Tags and jsp variable


At 10.37 04/07/01 -0400, you wrote:
>Andrea Gianni wrote:
>
>>Hi
>>1^ Problem :
>>I tryed this
>><MT:MiaTagLibrary initValue="<%=initValues%>" >
>>         <jsp:include page="pp.jsp" />
>></MT:MiaTagLibrary>
>
>can i see your code in MiaTagLibrary
Here the code, what I don't understand is that If I put iside my tag a
static String al works

public class MiaTagLibrary extends BodyTagSupport {

     static int cont =0;
     private String initValue="-1";
     /** Creates new MiaTagLibrary */
     public MiaTagLibrary()
     {
     }

     public void setInitValue(String nval)
     {initValue=nval;}

     public String getInitValue()
     {return(initValue);}


     public int doStartTag()
     {
         try
         {

         // Here I search barba, a String defined in the jsp


pageContext.getOut().print("----------------------"+pageContext.getAttribute
("barba",PageContext.PAGE_SCOPE)+"<br>");


         }
         catch(Exception e)
         {e.printStackTrace();}

         return EVAL_BODY_TAG;
     }

     public int doAfterBody() throws JspTagException
     {
         try
         {


             BodyContent bc = getBodyContent();
             String corpo = "vuoto";
             if (bc!=null)
              corpo= bc.getString();
             getPreviousOut().print("Il tag ha corpo "+corpo);

         }
         catch(Exception e)
         {e.printStackTrace();}
         return SKIP_BODY;
     }

    public int doEndTag()
    {
         return EVAL_PAGE;
    }
}



>>2^ Problem
>>how I can read in a tagLib a Java variable defined in a jsp Page directly
?
>>I think that I can use pageContext(<name of the variable>, 1); but don't
>>work.
>
>
>use TagExtraInfo.

Sorry I don't understand, I have a JSP like this

<%
         String barba="pippo";
         String p2="pluto";
...
%>

and I want to read these variables in my tag ( by the way I need to access
all the variables defined in the jsp without knowing them ), how the
tagExtraInfo should be written ? ( all examples I read talk about the
opposite problem, put a tag variable into jsp ).

Thanks

A.G.

*******************************
Ing. Andrea Gianni
Software Engineer
Gruppo Monetica e Servizi
Area Internet Professional
Infogroup S.p.a.
Via delle Panche, 140
50141 Firenze
Tel. 055.436.5647
Fax. 055.436.5735
e-mail [EMAIL PROTECTED]


Reply via email to