Custom taglib access the variable of jsp in the tag class

Hi guys:
I have a question about taglib.the scenario below
there are a set of tag,they all need to access a variable that declare in the jsp.yes ,I can use the approach like this,
first I declare a variable
<%!String variable="test";%>
then pass the value
<myTag:hello att="<%=variable%>"/>,but I think that's stupid,because all tags access the same variable.why not get the variable in tag class?
for example
public int doStartTag() {
String variable=;//get the variable at here
I mean,I want to get the variable's value in my tag class directly without passing parameter in the jsp via attribute of tag ?
can I do like this?if yes,how can I?
thanks advance!

Hi,
Review pageContext, TagSupport from the JSP and Tag Extensions API. You can put the variable into any of the four scopes and retrieve it using the pageContext object.

Similar Messages

  • Accessing the inner class written inside the method

    Hi all,
    Can any of you tell me how to access the inner class's method which is written inisde the outer class's method. THe code fragment is
    class Outer
    private static final int ID = 3;
    public String name;
    public void methodA( int nn )
    final int serialN = 11;
    class inner
    void showResult()
    System.out.println( "Rslt= "+ID );
    } // end class inner
    // new inner().showResult();
    } // end methodA
    class Sample
    public static void main(String a[])
    //access the showResult of Inner class??
    Thanks in advance.
    aah

    class Outer {
      private static final int ID = 3;
      public String name;
      public void methodA( int nn ) {
        final int serialN = 11;
        class inner {
          void showResult() {
            System.out.println( "Rslt= "+ID );
        } // end class inner
        new inner().showResult();
      } // end methodA
    class Sample {
      public static void main(String a[]) {
        new Outer().methodA(5);
    }

  • Transaction to add custom message to the message class

    Hello
    Can somebody tell me transaction name to add custom message to the message class (ZBW)
    CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
    EXPORTING
    I_CLASS = 'ZBW'
    thanks

    Hi,
    The tcode is SE91. Give this message class and add the message to it.

  • How to access the parent class variable or object in java

    Hi Gurus,
    I encounter an issue when try to refer to parent class variable or object instance in java.
    The issue is when the child class reside in different location from the parent class as shown below.
    - ClassA and ClassB are reside in xxx.oracle.apps.inv.mo.server;
    - Derived is reside in xxx.oracle.apps.inv.mo.server.test;
    Let say ClassA and ClassB are the base / seeded class and can not be modified. How can i refer to the variable or object instance of ClassA and ClassB inside Derived class.
    package xxx.oracle.apps.inv.mo.server;
    public class ClassA {
        public int i=10;
    package xxx.oracle.apps.inv.mo.server;
    public class ClassB extends ClassA{
        int i=20;   
    package xxx.oracle.apps.inv.mo.server.test;
    import xxx.oracle.apps.inv.mo.server.ClassA;
    import xxx.oracle.apps.inv.mo.server.ClassB;
    public class Derived extends ClassB {
        int i=30;
        public Derived() {
           System.out.println(this.i);                  // this will print 30
           System.out.println(((ClassB)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassB
           System.out.println(((ClassA)this).i);  // error, but this will print 20 if Derived class located in the same location as ClassA
        public static void main(String[] args) { 
            Derived d = new Derived(); 
    Many thanks in advance,
    Fendy

    Hi ,
    You cannot  access the controller attribute instead create an instance of the controller class and access the attribute in the set method
    OR create a static method X in the controller class and store the value in that method. and you can access the attribute by 
    Call method class=>X
    OR if the attribute is static you can access by classname=>attribute.
    Regards,
    Gangadhar.S
    Edited by: gangadhar rao on Mar 10, 2011 6:56 AM

  • Why can't this program access the private class

    All,
    If you could give me some help I would appreciate it, as I have been worrying this issue for some time now and cannot figure out why this program will not compile. It tells me that there are a number of errors, and it appears that these errors are due to the fact that it will not allow me to reach from the private class to the primary for variables. Now, I have seen another program that is very similar and it does not have these issues. IF someone would explain to me what is going on here I think that I could fix it. Thanks
       import java.io.*;
       import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import java.text.*;
       import java.util.*;
       import java.lang.*;
        public class MortgageGUIv4_1 extends JFrame
           public static void main(String[] args)
             new MortgageGUIv4_1();
          double MP, calcAPR, APR, adjustAPR, annualAPR;
          double monthTerm, userTerm;
          double userPrin;
          boolean user = false;
          String headers = "Payment No. \t\tRemainging Balance \tInterest Paid";
          String []loanRates = {"7 years at 5.35%,15 years at 5.5, 30 years at 5.75%"};
           public MortgageGUIv4_1()
             ButtonListener b1 = new ButtonListener();
             JPanel firstRow = new JPanel();
             JPanel fourthRow = new JPanel();
             JPanel fifthRow = new JPanel();
             JPanel sixthRow = new JPanel();
             JPanel seventhRow = new JPanel();
             JPanel fieldPanel = new JPanel();
             JPanel buttonPanel = new JPanel();
             JPanel buttonPanel3 = new JPanel();
             JLabel userPrinLabel = new JLabel("Principle:  ");
             JTextField userPrinvalue = new JTextField(10);
             ButtonGroup loanGroup = new ButtonGroup();   
             JLabel outputLabel = new JLabel("Click to see your payment");
             JButton buttonSubmit = new JButton("Submit");
             buttonSubmit.addActionListener(b1);
             JLabel outputLabel3 = new JLabel("Click here to clear Data");
             JButton buttonClear = new JButton("Clear");
             buttonClear.addActionListener(b1);
             JLabel mortgagePayment = new JLabel ("Your Monthly Payments are");
             JTextField totPayment = new JTextField(10);
             JComboBox termRateBx = new JComboBox(loanRates);
             JLabel termRateLbl = new JLabel("Select a Term and Rate from the options listed");
             JTextArea pymntTable = new JTextArea(headers, 10, 50);
             JScrollPane scroll = new JScrollPane(pymntTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
             try
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                 catch(Exception e)
                   JOptionPane.showMessageDialog(null,"The UIManager could not set the Look and Feel for this applicatoin.", "Error",
                      JOptionPane.INFORMATION_MESSAGE);
             MortgageGUIv4_1 winPane = new MortgageGUIv4_1();
             winPane.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             winPane.setSize(300,300);
             winPane.setTitle("Dan's Mortgage GUI System");
             winPane.setResizable(false);
             winPane.setLocation(200,100);
             winPane.setVisible(true);
             Container cont = getContentPane();
             cont.setLayout((new BorderLayout()));
             fieldPanel.setLayout(new GridLayout(8,1));
             FlowLayout rowSetup = new FlowLayout(FlowLayout.CENTER, 5,3);
             firstRow.setLayout(rowSetup);
             fourthRow.setLayout(rowSetup);
             fifthRow.setLayout(rowSetup);
             sixthRow.setLayout(rowSetup);
             seventhRow.setLayout(rowSetup);
             buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
             buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
             firstRow.add(userPrinLabel);
             firstRow.add(userPrinvalue);
             fourthRow.add(mortgagePayment);
             fourthRow.add(totPayment);
             fifthRow.add(termRateBx);
             fifthRow.add(termRateLbl);
             sixthRow.add(scroll);
             fieldPanel.add(firstRow);
             fieldPanel.add(fourthRow);
             fieldPanel.add(fifthRow);
             fieldPanel.add(sixthRow);
             fieldPanel.add(seventhRow);
             buttonPanel.add(buttonSubmit);
             buttonPanel.add(buttonClear);
             cont.add(fieldPanel, BorderLayout.CENTER);
             cont.add(buttonPanel, BorderLayout.SOUTH);
           private class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                Object source = e.getSource();
             //used the term user because this is the user input.  When the user inputs a correct value then the program moves on
                do
                   //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(userPrin <0)
                      JOptionPane.showMessageDialog(null,"The Principle value is out of range.  Please choose a value that is greater than 0", "Error",
                         JOptionPane.INFORMATION_MESSAGE);
                   else user=true;
                }while (!user);
                if(source == buttonSubmit)
                //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(selection.equals(loanRates[0]))
                      APR = 535 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 7 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[1]))
                      APR = 550 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 15 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[2]))
                      APR = 575 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 30 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   MP = userPrin * (APR / calcAPR);
                   DecimalFormat twodigits = new DecimalFormat("#,###.##");
                //The system will now render the monthly payment amount
                   totPayment.setText("$" + twodigits.format(MP));
                   double loanBal, newLoanBal, mnthlyIntPd, mnthlyPrinPd;
                   for (int i = 0; i >= monthTerm;i++)
                      newLoanBal = loanBal;
                      mnthlyIntPd = loanBal * APR;
                      mnthlyPrinPd = MP - mnthlyIntPd;
                      loanBal = loanBal - mnthlyPrinPd;
                      pymntTable.append("\n"+i+ "\t\t" + twodigits.format(loanBal)+ "\t\t" + twodigits.format(mnthlyIntPd));
                if(source == buttonClear)
                   userPrinvalue.setText("");
                   pymntTable.setText(headers);
       }Dan

    Thank you one and all, in part to what you said here I when through and obviously had to make some serious changes to the code. Now it will compile however, when I try to run it I am getting the following error. do not use MortgageGUIv4_1.add() use MortgageGUIv4.1.getContentPane.add instead. I am at a loss for this one, as when I looked it up the only difference was that the one is awt and the other is swing. Could someone please let me know what I am missing.
    Thanks
    Dan
       import java.io.*;
       import java.awt.*;
       import java.awt.event.*;
       import javax.swing.*;
       import javax.swing.event.*;
       import javax.swing.border.*;
       import java.text.*;
       import java.util.*;
       import java.lang.*;
        public class MortgageGUIv4_1 extends JFrame
           public static void main(String[] args)
             new MortgageGUIv4_1();
          double MP, calcAPR, APR, adjustAPR, annualAPR;
          double monthTerm, userTerm;
          double userPrin;
          boolean user = false;
          String headers = "Payment No. \t\tRemainging Balance \tInterest Paid";
          String loanRates[] = {"7 years at 5.35%","15 years at 5.5", "30 years at 5.75%"};
              private JLabel userPrinLabel, outputLabel, outputLabel3, mortgagePayment, termRateLbl;
              private JTextField userPrinvalue, totPayment;
              private JButton buttonClear, buttonSubmit;
              private JComboBox termRateBx = new JComboBox(loanRates);
              private JTextArea pymntTable;
              private JScrollPane scroll = new JScrollPane(pymntTable);
           public MortgageGUIv4_1()
             ButtonListener b1 = new ButtonListener();
               this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             this.setSize(900,500);
             this.setTitle("Dan's Mortgage GUI System");
             this.setLocation(240,0);
             this.setVisible(true);
             JPanel winPane = new JPanel();
             JPanel userPrinciple = new JPanel();
             userPrinLabel = new JLabel("Principle:  ");
             userPrinvalue = new JTextField(10);
             userPrinciple.add(userPrinLabel);
             userPrinciple.add(userPrinvalue);
             ButtonGroup loanGroup = new ButtonGroup();
             outputLabel = new JLabel("Click to see your payment");
             buttonSubmit = new JButton("Submit");
             buttonSubmit.addActionListener(b1);
             outputLabel3 = new JLabel("Click here to clear Data");
             buttonClear = new JButton("Clear");
             buttonClear.addActionListener(b1);
               JPanel results = new JPanel();
               mortgagePayment = new JLabel ("Your Monthly Payments are");
             totPayment = new JTextField(10);
               results.add(mortgagePayment);
             results.add(totPayment);
               JPanel comboBx = new JPanel();
             termRateLbl = new JLabel("Select a Term and Rate from the options listed");
               comboBx.add(termRateBx);
             comboBx.add(termRateLbl);
             pymntTable = new JTextArea(headers, 10, 50);
             JScrollPane scroll = new JScrollPane(pymntTable, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
             try
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
                 catch(Exception e)
                   JOptionPane.showMessageDialog(null,"The UIManager could not set the Look and Feel for this applicatoin.", "Error",
                      JOptionPane.INFORMATION_MESSAGE);
             winPane.add(userPrinciple);
             winPane.add(comboBx);
             winPane.add(results);
               winPane.add(scroll);
               winPane.add(outputLabel);
               winPane.add(buttonSubmit);
             winPane.add(outputLabel3);
             winPane.add(buttonClear);
               this.add(winPane);
           private class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent e)
                Object source = e.getSource();
                String selection = (String)termRateBx.getSelectedItem();
             //used the term user because this is the user input.  When the user inputs a correct value then the program moves on
                do
                   //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(userPrin <0)
                      JOptionPane.showMessageDialog(null,"The Principle value is out of range.  Please choose a value that is greater than 0", "Error",
                         JOptionPane.INFORMATION_MESSAGE);
                   else user=true;
                }while (!user);
                if(source == buttonSubmit)
                //captures the user data entered in the text field and converts it to double
                   String enterAmount = userPrinvalue.getText();
                   userPrin = Double.parseDouble(enterAmount);
                   if(selection.equals(loanRates[0]))
                      APR = 535 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 7 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[1]))
                      APR = 550 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 15 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   if(selection.equals(loanRates[2]))
                      APR = 575 / (12 * 100);  //The APR is converted from whole number to % and reduced to the monthly rate
                      monthTerm = 30 * 12;  //The Term must be converted to months
                      adjustAPR= 1 + APR;
                      calcAPR = 1 - Math.pow(adjustAPR, -monthTerm);
                   MP = userPrin * (APR / calcAPR);
                   DecimalFormat twodigits = new DecimalFormat("#,###.##");
                //The system will now render the monthly payment amount
                   totPayment.setText("$" + twodigits.format(MP));
                   double loanBal = userPrin, newLoanBal, mnthlyIntPd, mnthlyPrinPd;
                   for (int i = 0; i >= monthTerm;i++)
                      newLoanBal = loanBal;
                      mnthlyIntPd = loanBal * APR;
                      mnthlyPrinPd = MP - mnthlyIntPd;
                      loanBal = loanBal - mnthlyPrinPd;
                      pymntTable.append("\n"+i+ "\t\t" + twodigits.format(loanBal)+ "\t\t" + twodigits.format(mnthlyIntPd));
                if(source == buttonClear)
                   userPrinvalue.setText("");
                   pymntTable.setText(headers);
       }

  • Newbie:what is the time to call release() in the tag class?

    I found the tag will be only instance one times in the jsp server, so the private varable can be access by another request call. there are one release() method in the interface defined, however, I have ever saw any instance to call it explicity, right now I call it in the doEndTag, is that all right?
    frederick

    The JSP engine will call release() when it is reusing a tag instance with different parameters. You don't need to explicitly call release() in the code.

  • Problem accessing session variables in JSP

              Hi all,
              i am retrieving the value of session variables in a JSP page. the session varibale
              is set at the
              server side. sometimes the jsp is able to retrieve the value and sometimes it
              doesn't.
              Thanks & Regards
              Tarun
              

    if getAttribute return null so there is no such session attribute,anyway
              check your browser if cookies are enabled.
              "Tarun Mangal" <[email protected]> wrote in message
              news:400759e9$[email protected]..
              >
              > Hi all,
              > i am retrieving the value of session variables in a JSP page. the session
              varibale
              > is set at the
              > server side. sometimes the jsp is able to retrieve the value and sometimes
              it
              > doesn't.
              >
              > Thanks & Regards
              > Tarun
              

  • Problem accessing session variable from jsp

    Hi!
    I get an error retrieving a session variable from inside a JSP declaration scriptlet....
    Something like this code in a JSP page:
    <%!
    public void funtion1() {
    String parameter1 = session.getAttribute("parameter1");
    %>I have seen that I have available getContextServer() method and from there I could call getAttribute("parameter1") . But the thing is that the attribute I want to retrieve was stored in session by another Jsp page.
    Any solutions are welcome
    Cheers
    Victor

    Appropriately the above is one the reasons also You cannot use JSP implicit objects from the declaration tag. However we can think of a small workaround by passing the reference like the one discussed below
    <%!public void funtion1(HttpSession session) {
    String parameter1 = session.getAttribute("parameter1").toString();
    }%>
    <% funtion1(session);%>Hope that helps :)
    REGARDS,
    RaHuL

  • Custom taglibs w/ JSP features

    Hello Together,
    I am currently facing a little problem:
    I use custom taglibs for rendering certain web elements (lets say widgets etc.). The reason is greater reusability and full integration into the runtime. However, what do you recommend on how to render such components?
    As far as i know, there are only two solutions:
    - embedding markup (e.g. XHTML, XML...) into the tag class (not so good, especially when large chunks of markup)
    - reading from markup templates located on the file system and populating them w/ data (slow?).
    What do you use for custom taglibs that are to render markup contents (thus, no flow taglibs)?
    I know that i can fallback to pure JSPs, but there is no elegant way calling them with parameters. The reason is that i have "abstract control classes" with some properties. According to these properties, my taglib renders the control. When doing this with a JSP fragment, there is no "cool" way:
    the class proto: an GUI class with properties
    - id
    - caption
    - state
    - etc.
    -- taglib example --
    <some:guiElement obj="${controls.current}" method="xml" />
    This taglib can query all properties by the obj reference and render.
    -- JSP equivalent w/ JSTL call --
    <c:import url="/base/guiElement.jsp?id=${controls.current.id}&caption=${controls.current.caption}[...]" />
    This is bad design, and all params have to be passed seperately (or not?).
    You see, Taglibs are quite more handy to use, as you know. But i am missing JSP features in taglibs, such as how to do an <c:import /> from within an taglib etc.
    Another thing in mind is themeability. One can use a copy of the JSP fragment and modify its visual appearance, but w/ taglibs, that is more harder (except when using markup templates).
    Does anyone knoe how to marry JSP featires into custom taglibs?
    Sorry for that long posting :-)
    Greetings, Timo

    Hello,
    Just an answer to myself and anyone who is interested:
    The solution to my problem is migrating to JSP 2.0 where you can use tag template files.
    Thus, if possible, upgrading to JSP 2.0 + Servlet 2.4 does the job.
    Greetings, Timo

  • In the *.tld,what's the use of the tag " variable "

    For the jsp taglib technology.
    In the *.tld file,accroding to the "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd"
    there is an optional tag "<variable>".
    In some document , i saw an example as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN" "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
    <taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.2</jsp-version>
    <short-name>map</short-name>
    <tag>
    <variable>
    <name-from-attribute>id</name-from-attribute>
    <variable-class>java.util.Map</variable-class>
    <scope>AT_BEGIN</scope>
    </variable>
    </tag>
    </taglib>
    What use of this?
    Can anybody give me an simple example to explain this?
    Thank u!

    Thank u very much?
    But i want to know, if I had set the <attribute> tag
    as the example i had given.Do you mean attribute, or variable in the example you gave?
    Here, I will give you a full example. This tag will set a new variable (given by an attribute name) a value provided by another attribute, and puts that variable into one of the four scopes (page, request, session, application)
    You would use this tag like this:
    <custom:setValue var="theVar" value="What I want" scope="page"/>
    Where var = the name of the variable that will be exported
    value = The value to assign to the variable
    scope = the scope to put the variable into.
    package tags;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.http.jsp.*;
    import javax.servlet.http.jsp.tagext.*;
    public class SetValueTag extends SimpleTagSupport
      private String varName, scope, value;
      public void setVar(String var) { varName = var; }
      public void setScope (String s) { scope = s; }
      public void setValue(String val) { value = val; }
      public void doTag() throws JspException, IOException
        PageContext context = (PageContext)getJspContext();
        if ("application".equals(scope)) context.setAttribute(varName, value, PageContext.APPLICATION_SCOPE);
        else if ("session".equals(scope)) context.setAttribute(varName, value, PageContext.SESSION_SCOPE);
        else if ("request".equals(scope)) context.setAttribute(varName, value, PageContext.REQUEST_SCOPE);
        else context.setAttribute(varName, value, PageContext.PAGE_SCOPE);
    }The tag in your tld would look like this:
      <tag>
        <description>Set the value of a scoped variable</description>
        <name>setValue</name>
        <tag-class>tags.SetValueTag</tag-class>
        <body-content>empty</body-content>
        <attribute>
          <description>The name of the exported variable</description>
          <name>var</name>
          <required>true</required>
          <rtexprvalue>false</rtexprvalue>
          <type>java.lang.String</type>
        </attribute>
        <attribute>
          <description>The value to give the exported variable</description>
          <name>value</name>
          <required>true</required>
          <rtexprvalue>true</rtexprvalue>
          <type>java.lang.String</type>
        </attribute>
        <attribute>
          <description>The the scope of the exported variable</description>
          <name>scope</name>
          <required>false</required>
          <rtexprvalue>false</rtexprvalue>
          <type>java.lang.String</type>
        </attribute>
        <variable>
          <name-from-attribute>var</name-from-attribute>
          <variable-class>java.lang.String</variable-class>
          <scope>AT_BEGIN</scope>
          <declare>true</declare>
        </variable>
      </tag>>
    Then what should i do in the TagHandler programme(A
    javabean handle the tag)?
    And what should i do in the JSP page ?
    Can u give me an simple example?

  • How to use session variable in JSP function  & How to use both JSP  Servlet

    Hi,
    I am new to JSP and servlets
    Still I am devloping a website in JSP. I am not mixing JSP with servlets, but I do create Java files for bean, logic and database works.
    I try to keep the hard coding part out of JSP.
    I dont how to use both JSP and Servlets in combination.
    Hence If needed I write some functions in JSP.
    but it gives me error
    +<%! public void abc()+
    +{+
    int intUserId = Integer.valueOf((Integer) session.getAttribute("MySession_UserID"));
    +}+
    +%>+
    Saying cannot find symbol session
    1) So can u please tell how can I access session variables within JSP function
    2) And also give me some links/tutorials about useing both JSP and Servlets in combination.
    Thanks
    Venkat

    The application architecture when you use Servlets and JSP in a standard MVC pattern is explained here (under the heading "Integrating Servlets and JSP Pages") and here ...

  • Extending functionality from existing custom taglib

    Hi!
    I'm trying to extend the functionality of an already existing custom taglib. To test this possibility I�ve so far created a small taglib containing two tags. QbeTag.java and QbeSumTag.java.
    The QbeTag class handles a database connection and constructs a table showing the result of a query passed in as an attribute in the tag. (The database contains a �dummy table� holding information about persons.)
    Now let�s pretend that I don�t have the source code for the QbeTag but need to/ want to extend its functionality. For instance:
    In the QbeSumTag I want to summarize all the persons ages and present it in a new text field somewhere else on the page.
    To do this I probably need to access the QbeTag class from the QbeSumTag class, or is there any other way to achieve this wanted functionality?
    Up to this point:
    What I�ve tried is to implement the QbeSumTag so that It extends the QbeTag class. This means that I now can access the doStartTag, doEndTag, and so on methods from the QbeSumTag by typing super.doStartTag().
    The problem with this approach is that this way only gives me the possibility to run the methods not altering the process it self and I can�t alter the out stream. A syntax like:
    public int doStartTag() throws JspException
    return super.doStartTag();
    Will only result in a call for the QbeTag�s doStartTag() method to run and do it�s stuff.
    Is there any way I can solve this or am I stuck? Maybe one approach would be to nest the QbeSumTag with the QbeTag wich would mean that there will be a dependency between the tow tags.
    I believe that this question is quite difficult to answer but it could be the starting point for an interesting discussion. Hasn�t anyone tried to extend the functionality of the Jakarta taglib, say the DB tags or Mail tag.
    All thoughts and replies will great fully received.
    /Daniel

    Well, the answer to this is the same as the answer to extending any third party classes... it depends on how the original class was created.
    If the original class was designed with extension in mind, then (hopefully) its realy functionality will be isolated to a series of protected methods (that you would have access to) and private methods (you would not have access to).
    You would use the public and protected methods to retrieve the data you need to do your work, or override those ones whose work you want to replace (for instance, if it has a protected displayOutput(Map dataMap) method, you are in luck!).
    If everything is done giving you know access to the pieces, then you may be stuck providing a tag that has the original tag nested inside it. Buffer the output from the original tag and parse it, retrieving the info you need, then output your own stuff...

  • How can I assign javascript variables to jsp or java variables.?

    How can I assign javascript variables to jsp or java variables.?

    See I have generated some variables in the javascript which is on the jsp page. I want to assgin these variables to the jsp vaiables. Or how can I access javascript variables from jsp on the same jsp page.

  • Accessing session variables

    Hi ,
    I have session variable defined using portals (forms or plsql portlets).
    Can i access these variables using jsp portlets ??
    This is an urgent requirement ..
    Regards,
    Vijaya

    "145822",
    If your application with application id 100, for example, uses a common authentication scheme with application 200 (using the same cookie name in the case of an HTML DB style authentication scheme), then the two applications can run in the same session. A potential benefit of this, even if the two apps are not intricately related, is that the user has only to authenticate once per new session and will have access to both apps. If you set it up this way, then app 100 can access app 200's items in the same session using this function from within app 100:  htmldb.application.fetch_app_item(p_item=>'ITEM_NAME',p_app=>200);Scott

  • Custom component/tag class:  ---which setters/getters do what?

    Hi
    I'm trying to create a custom component, but, there is a major concept that I do not understand...
    ---What are the setters/getters in the "component" class used for?...
    ---What are the setters/getters in the "tag" class used for?
    Another way of asking is...
    ---Which setters/getters are used simply to keep track of attribute name/id/key?
    ---Which setters and getters refer to the actual objects that the attribute names point to?
    The reason for my confusion is that nearly all "custom component" examples I've seen thus far, utilize attributes that point to "String" objects... (i.e., as opposed to ArrayList, HashMap, etc)...
    This makes it difficult for me to distinguish whether the String values in the getters/setters are referring to the String name/"id" of the attribute...or, the String "value" of the attribute...
    I have not been able to verify how I should code the getter/setters (and type casts) for other kinds of objects like ArrayLists, HashMaps, etc
    For example, a typical logic mechanism Ive seen in the custom "tag" examples is as follows...
    in a "tag" class...
            if( tabledata != null )
                if (isValueReference (tabledata))
                    FacesContext context = FacesContext.getCurrentInstance ();
                    Application app = context.getApplication ();
                    ValueBinding vb = app.createValueBinding (tabledata);
                    component.setValueBinding ("tabledata", vb);
                else
                    component.getAttributes ().put ("tabledata", tabledata);
    in the "component" class...
        public void setTabledata (List tabledata)
            this.tabledata = tabledata;
        public List getTabledata ()
            if(null != tabledata)
                return tabledata;
            ValueBinding _vb = getValueBinding ("tabledata");
            if(_vb != null)
                return (List)_vb.getValue (getFacesContext ());
            else
                return null;
        }...considering the above code,
    ---when/where should the "tabledata" variable be referring the "name/id" of the attribute?...
    ---when/where should the "tabledata" variable be referring to the "value" of the attribute?...
    ...as, I need to change the type casting to adjust to what it should be...
    ***NOTE: This is one error that I'm getting, and I believe it is because I do not understand how getter/setter is used in "component" and "tag" classe, i.e., :
    "org.apache.jasper.JasperException: jsp.error.beans.property.conversion
         org.apache.jasper.runtime.JspRuntimeLibrary.getValueFromPropertyEditorManager(JspRuntimeLibrary.java:885)"...
    Thanks for any help on this!
    sd

    The "tabledata" variable always refers the local value of the attribute.
    When using a value binding to some backing bean,
    the local value is null and the model value is owned by the bean.
    You don't need any casting in the tag class nor the component class.
    The setters/getters in the component class specify the type of the attributes.
    Conversion from/to String to/from the type is done automatically if possible.
    When the automatic conversion is impossible, you should specify f:converter
    for the attribute.

Maybe you are looking for