Passing params to custom tag from jsp

Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
Something like this:
// processed tag
<a href="mypage.jsp?page=1">Next page</a>
// clicking "Next Page"
<a href="mypage.jsp?page=2">Next page</a>
// jsp
<taglib:tag param="<%=getPageNumber()%>"  />
// in tag lib
private pagenumber=1;
            pagenumber++;
getPageNumber(){
return pagenumber;
setPageNumber(int pagenumber){
   this.pagenumber=pagenumber
}I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
Any advice would be greatly appreciated.
Thanks :)

Hi all, I have a problem passing params back to my custom tag. The tag handler has a "getPageNumber()" method which returns a value. Initially the value is set and if a link is clicked it passes that param to the tag handler. I am trying to get this value from the tag handler to update the value on the link parameter.
Something like this:
// processed tag
<a href="mypage.jsp?page=1">Next page</a>
// clicking "Next Page"
<a href="mypage.jsp?page=2">Next page</a>
// jsp
<taglib:tag param="<%=getPageNumber()%>"  />
// in tag lib
private pagenumber=1;
            pagenumber++;
getPageNumber(){
return pagenumber;
setPageNumber(int pagenumber){
   this.pagenumber=pagenumber
}I'm not sure if this is the best way to do this or if what I am trying to do is even possible.
Any advice would be greatly appreciated.
Thanks :)

Similar Messages

  • Urgent-how to access custom tag from jsp tag

    I have a problem accessing a custom tag from a jsp expression.
    Details: I have a custom tag that returns a string variable. I need to access that variable from jsp expression <%%>.
    Can any body help me?

    Tags don't "return" values as in the normal sense.
    They can only support TEI (Tag Extra Information) that just stuffs a declared variable into the page's state.
    For example, if the tag class had a public method called getValue(), you could do the following:
    <xmp:mytag id="foo"/>
    <%
    out.println("value is " + foo.getValue());
    %>

  • Calling jsp custom tag from jsp expression

    hi there,
    I have a problem calling oracle(or any other) custom tag from inside a jsp expression.(i.e.)embeding <jbo:tagname...> into <%......%>.
    For example:
    I need to get the value of a jsp parameter, but the parameter name is dynamic (retrieved from a DataBase)
    So I though it would be something link that:
    <%=request.getParameter(<jbo:ShowValue datasource="ds" dataitem="ParamName" ></jbo:ShowValue>) %>
    where <jbo:ShowValue is an Oracle custom tab that retrieves the value of a certain dataItem(certain field).
    But it does not work.........
    if any body can tell me how to overcome, or work around it, I'll be so pleased.
    Regards,
    Remoun Anwar

    Hi,
    You get the custom tag output into a hidden variable (say 'key') and use the request.getParameter("key")
    Hope u got the answer...
    Regards
    ravi

  • How to call & pass values to custom page from seeded page table region

    Hi All,
    can anyone tell me how to call & pass values to custom page from seeded page table region(Attribute is not available in seeded page VO)
    it is urgent. plssss
    Regards,
    purna

    Hi,
    Yes, we do this by extending controller, but you can also try this without extending controller.
    1. Create Submit Button on TableRN using personalization.
    2. Set "Destination URI" property to like below
    OA.jsp?page=/<yourname>/oracle/apps/ak/employee/webui/EmpDetailsPG&employeeNumber={@EmployeeId}&employeeName={@EmployeeName}&retainAM=Y&addBreadCrumb=Y
    Give your custom page path instead of EmpDetailsPG.
    EmployeeId and EmployeeName are VO attributes(Table Region)
    If you dont have desired attribute in VO, then write logic in your custom page controller to get required value using parameters passed from URL path.
    In this case, only personalization will do our job. Hope it helps.
    Thanks,
    Venkat Y.

  • How to use custom tag in jsp

    sir
    plz tell me how to use custom tag in jsp.plz describe it.
    i will be thankful to u

    Do you want to use taglibs or develop custom tags? Either way take a look at these:
    http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPTags.html
    http://www.stardeveloper.com/articles/display.html?article=2001081301&page=1
    http://www.onjava.com/pub/a/onjava/2000/12/15/jsp_custom_tags.html
    http://jakarta.apache.org/taglibs/tutorial.html
    http://www.ibm.com/developerworks/edu/j-dw-java-custom-i.html
    http://www.herongyang.com/jsp/tag.html

  • Exception while passing null as param in custom tag

    Hi,
    I am using Oracle 10g AS(10.1.2). In my j2ee application,while passing NULL as parameter in custom tags, i am getting exception. But it was working fine with oracle 9i as.
    for example:
    This is my code in jsp:
    <%
    String str =null;
    %>
    <test:getInfo id="<%=str%>" />
    While executing the above code, I am getting the following exception :
    javax.servlet.ServletException
    at com.evermind.server.http.EvermindPageContext.handlePageThrowable(EvermindPageContext.java:595)
    at com.evermind.server.http.EvermindPageContext.handlePageException(EvermindPageContext.java:537)
    at ListAlerts.jspService(_ListAlerts.java:1827)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
    at com.evermind.server.http.GetParametersRequestDispatcher.newInclude(GetParametersRequestDispatcher.java:80)
    at com.evermind.server.http.GetParametersRequestDispatcher.include(GetParametersRequestDispatcher.java:34)
    at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
    at Content.jspService(_Content.java:181)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.include(ServletRequestDispatcher.java:121)
    at com.evermind.server.http.GetParametersRequestDispatcher.newInclude(GetParametersRequestDispatcher.java:80)
    at com.evermind.server.http.GetParametersRequestDispatcher.include(GetParametersRequestDispatcher.java:34)
    at com.evermind.server.http.EvermindPageContext.include(EvermindPageContext.java:267)
    at Main.jspService(_Main.java:360)
    at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:350)
    at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:509)
    at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:413)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:222)
    at org.apache.struts.action.ActionServlet.processActionForward(ActionServlet.java:845)
    at org.apache.struts.action.ActionServlet.process(ActionServlet.java:734)
    at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
    at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
    at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:224)
    at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:133)
    at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:192)
    at java.lang.Thread.run(Thread.java:534)
    Please help me....

    Hello,
    I do not remember exactly how the null where handle in Oracle 9iAS. Have you tested what is the differences in the way the <%= null %> is returned in both 9iAS and 10.1.2?
    You may just have to modify the way the value is sent to the bean from the tag.
    Regards
    Tugdual Grall

  • Custom Tags in JSP

    I am new to using custom tags. Is there a nice book or site which I could read on custom tags.
    Also, I kind of understand custom tags but not completely confident.
    I have a JSP that uses two custom tags, flight and segment. Basically, goes through each segment with flight tag and prints out attribute of segment with Segment tag. The code looks like this.
    <flifo:flight isParent="true" fromParent="true" >
              <td bgcolor="<%=bgcolor%>" width="94" valign="top" class="t7">
                        <%-- Print FLIGHT NUMBER --%>
                   Flight
                        <b><flifo:segment fromParent="true" attribute="flight_num" /></b>
                        <br>
    </flifo:flight>
    In the above code I just have flight_num but there are other attributes that it prints out. I want to check an attribute in segment and if it is ture then display some of the tags. How can I do it?

    This has helped me a lot in the past:
    http://java.sun.com/developer/Books/javaserverpages/cservletsjsp/chapter14.pdf
    ... and the book it's extracted from is very good too.

  • Accessing custom classes from JSP

    Hi Guys,
    I am having some problems accessing my custom classes from my JSP.
    1) I've created a very simple class, SimpleCountingBean that just has accessors for an int. The class is in the package "SimpleCountingBean". I compiled this class locally on my laptop and uploaded the *.class file to my ISP.
    2) I've checked my classpath and yes, the file "SimpleCountingBean/SimpleCountingBean.class" is located off of one of the directories listed in the classpath.
    3) When I attempt to use this class in my JSP, via the following import statement:
    import "SimpleCountingBean.*"
    I get the following compile error
    java.lang.NoClassDefFoundError: SimpleCountingBean/SimpleCountingBean
    I'm pretty sure that my classpath is properly setup because when I purposely garble the import statement, I get the "package not found" compile error.
    Do I need to upload some other files in addition to the class file? Any suggestions would of course be appreciated.
    Sonny.

    Trying to get some clearer view.. so don't mind..
    So you uploaded all your .jsp files into your account which is:
    home/sonny
    and it compiles and work. But custom classes doesn't seems to be working, where did you place your classes?
    From my knowledge of tomcat, classes are normally placed in, in this case:
    home/sonny/web-inf/classes
    Maybe it differs from windows enviroment to *nix enviroment.. well, I'm just saying out so if its not the case.. don't mind me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Custom tag and JSP = getOutputStream error

    Hi guys. I have a custom authorization tag as follows:
    package tags;
    import stuff;
    public class AuthenticatedTag extends TagSupport {
         public int doStartTag() throws JspException {
              try {
                   pageContext.forward("login.htm");
              } catch (Exception e) {
                   e.printStackTrace();
              return EVAL_PAGE;
         public int doEndTag() throws JspException {
              return EVAL_PAGE;
    }and a jsp page using this tag:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" errorPage="error.jsp" %>
    <%@ taglib uri="/WEB-INF/tags.tld" prefix="tags" %>
    <tags:myauth />
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>stuff
    </body>
    </html>When I point my browser to this jsp I get:
    org.apache.jasper.JasperException: getOutputStream() has already been called for this response
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:476)     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:383)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:315)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    Any ideas of what could be wrong? thx

    If you forward to the login.htm page, you should stop the rest of the current page evaluating. Just because you forwarded it, doesn't stop the flow of control in this page. It is trying to evaluate both the current page and the one that you forwarded to. You can only send one response
    Returning SKIP_PAGE from the doEndTag function should do the trick.
    I'm not sure that returning EVAL_PAGE or SKIP_PAGE from the doStartTag is legal. It should return SKIP_BODY or one of the EVAL_BODY options.
    In fact I think the whole thing should probably be done in the doEndTag for that reason.
    package tags;
    import stuff;
    public class AuthenticatedTag extends TagSupport {
         public int doEndTag() throws JspException {
              try {
                   pageContext.forward("login.htm");
                            return SKIP_PAGE
              } catch (Exception e) {
                   e.printStackTrace();
              return EVAL_PAGE;
    }I presume you will be putting in some sort of check to see if you should forward to login.html instead of evaluating the current page?
    Just as an alternative suggestion, a better way IMO is to implement this sort of logic as a filter, rather than putting a tag on a JSP page.
    Cheers,
    evnafets

  • Passing data to custom smartform from a custom program...

    Hello Gurus,
    Since, the function module gets generated dynamically at runtime when smartform is activated, I know that first I should use  "SSF_FUNCTION_MODULE_NAME" and pass custom smartform name to it to get the name of function module. Then I have to use call function '/XXXXXXXXX'.
    Now, I am writing a custom code and I want the data from my select program in custom program to be passed to smartform ? How can I pass the data from my custom program to smartform ? Do I pass it before using function module "SSF_FUNCTION_MODULE_NAME" ? If yes, how ?
    Regards,
    Rajesh.

    hi,
    u have to declare ur structures in form interface and can retrive the data from custom program.
    check this sample code.
    declare structure in interface.
    WA_MKPF TYPE MKPF.
    write ur custom code lik this.
    DATA: wahz TYPE zmemigo_form_header,
          wa_mkpf  TYPE mkpf.
    DATA: t_itemz LIKE zmemigo_form_item OCCURS 0,
          t_mseg   TYPE mseg OCCURS 0,
          waitemz TYPE zmemigo_form_item,
          waitem TYPE mseg.
    DATA : form_name TYPE tdsfname VALUE 'ZPS_STN'.
      DATA : fnc_module TYPE rs38l_fnam.
    SELECT SINGLE mblnr INTO wa_mkpf-mblnr FROM mseg
                CLIENT SPECIFIED WHERE  mandt EQ sy-mandt
                                   AND  mblnr EQ p_mblnr
                                   AND  mjahr EQ p_mjahr
                                   AND  bwart EQ '351'
                                   AND  shkzg EQ 'H'.
      CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
        EXPORTING
          formname                 = form_name
        VARIANT                  = ' '
        DIRECT_CALL              = ' '
        IMPORTING
         fm_name                  = fnc_module
        EXCEPTIONS
         no_form                  = 1
         no_function_module       = 2
         OTHERS                   = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
      CALL FUNCTION fnc_module
        EXPORTING
          wa_headz         = wahz
          wa_mkpf          = wa_mkpf
        TABLES
          it_itemz         = t_itemz
          it_mseg          = t_mseg
        EXCEPTIONS
          formatting_error = 1
          internal_error   = 2
          send_error       = 3
          user_canceled    = 4
          OTHERS           = 5.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.

  • Pass argument to custom tag

    Is there any way to pass a page-scope variable to a tag hanlder class? I have a variable fullname which I need to pass to the tag, so it can determine how to print it...I'm trying to avoid massive scriptlets in the middle of a complex page. The way it works is: A user logs in; the JSP page determines the user's fullname with a javabean, and then i want to pass that fullname to the tag, so it can either say "logged in as ..." or "not logged in" if the fullname="nobody".
    Or is there a much better architecture than what i'm proposing here?
    Thanks in advance,
    Laz

    Did you try putting the value of the name to the session? In your bean, you could create a method that would return a String that contains the name. And then you call that method in the JSP. for example:
    session.setAttribute("name", beanInstance.getName() );
    And then in the JSP where you need to display the name, you only have to get it by:
    out.println("You are logged in as " + session.getAttribute("name") );

  • Calling custom tags in jsp  with jsp:include

    Hi,
    I have a large jsp file , which uses jstl fmt tags for labels.
    Since the size of jsp was too big iand i was unable to compile it because of 64 kb class size limit,
    I removed the tag lib defination from the jsp file and put it in another jsp file. and used jsp:include to include this file inside the first jsp.
    It is compiling successfully but labels r not showing up.
    but when i use <%@include to include second jsp in the first one i get the labels properly.
    I cannot use <%@include as this starts giving me compilation error related with jsp class file size beyond 64 kb.
    Pls suggest why jsp:include is not working.
    thanks,
    Pramod

    Hi Anil,
    Ur suggestion was good but could not solve my problem.
    I have put a small sample code to illustrate the problem.
    labeldemo.jsp:
    <%-- <%@ include file="WDCComInitLabelsjunk.jsp" %> --%>
    <jsp:include page="WDCComInitLabelsjunk.jsp" flush="true" />
    <table width="100%" cellpadding="3" cellspacing="0" border="0" class="tablebg">
                                  <tr class="headtd">
                                       <td colspan="4"><span class="headtext"><fmt:message key="Cash_Management"/> </td>
                                  </tr>
                                  <tr> hi </tr>
                             </table>
                             </fmt:bundle>
    WDCComInitLabelsjunk.jsp:
    <%@ page language="java" %>
    <%@ page contentType="text/html"%>
    <%@ page import="com.tcs.wdc.core.*" %>
    <%@ page import="com.tcs.wdc.core.login.*" %>
    <%@ page import="com.tcs.wdc.core.service.navigation.*" %>
    <%-- Include tag library --%>
    <%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
    <%-- Get language from IDCUserSession & set it in session --%>
    <%
    /*SessionManager sm = new SessionManager(session);
    IDCUserSession ius = sm.getIDCUserSession();*/
    session.setAttribute("language","nl_NL");
    %>
    <%-- Set the locale for the language obtained --%>
    <fmt:setLocale value="${language}" />
    <fmt:bundle basename="labels" />
    If i uncomment the <%@ include file="WDCComInitLabelsjunk.jsp" %> tag in the code above it is working fine ,
    but it is not working with <jsp:include page="WDCComInitLabelsjunk.jsp" flush="true" />
    pls suggest.
    Thanks,
    Pramod

  • Custom tag in JSP

    MyTag currently extends from TagSupport. But still it complains this at runtime:
              weblogic.servlet.jsp.JspException: (line -1): Error in tag library at: 'my': er
              ror introspecting class: 'MyTag':
              weblogic.servlet.jsp.JspException: (line -1): Error in tag library at: 'my': cl
              ass MyTag doesn't implement javax.
              servlet.jsp.tagext.Tag
              at weblogic.servlet.jsp.StandardTagLib.jspException(StandardTagLib.java:
              138)
              at weblogic.servlet.jsp.StandardTagLib.processTag(StandardTagLib.java:24
              4)
              at weblogic.servlet.jsp.StandardTagLib.processTagElements(StandardTagLib
              .java:146)
              at weblogic.servlet.jsp.StandardTagLib.<init>(StandardTagLib.java:125)
              at weblogic.servlet.jsp.JspLexer.loadTagLib(JspLexer.java:87)
              at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE_BODY(JspLexer.java:38
              11)
              at weblogic.servlet.jsp.JspLexer.mTAGLIB_DIRECTIVE(JspLexer.java:3561)
              at weblogic.servlet.jsp.JspLexer.mDIRECTIVE(JspLexer.java:3422)
              at weblogic.servlet.jsp.JspLexer.mSTANDARD_THING(JspLexer.java:1760)
              

    yeah you should this is how you need to configure your web.xml
    <jsp-config>
                <taglib>
                     <taglib-uri>mycustomtag</taglib-uri>
                    <taglib-location>/WEB-INF/tld/DemoTags.tld</taglib-location>
                </taglib>
    </jsp-config>and at jsp level you can access it as
    <%@ taglib uri="mycustomtag" prefix="mytag" %>
    <mytag:property ..... />Hope that might help :)
    REGARDS,
    RaHuL

  • Passing variables between data tag and JSP-scriptlets

    Hi,
    There were some questions about this issue. However, the answers were not satisfactory.
    I would like to assign the value returned from data tag to a variable in JSP-scriptlets as follows:
    <%@ taglib uri="/webapp/DataTags.tld" prefix="jbo" %>
    <br>
    <jbo:ApplicationModule id="isae.OPKv1.OPKv1Module" configname="isae.OPKv1.OPKv1Module.OPKv1ModuleLocal" username="t1" password="t1"/>
    <br>
    <!-- a record is selected -->
    <jbo:DataSource id="ds" appid="isae.OPKv1.OPKv1Module" viewobject="AePk100View" whereclause=" <%= ic %> " />
    <br>
    <jbo:Row id="privRow" action="CURRENT" datasource="ds">
    <%
    String privName = (String) privRow.getAttribute("ArBau325"); // this is the suggestion of William Dwight (Jan 21, 2001 this forum)
    %>
    </jbo:Row>
    This code did not work. I have obtained an error :
    java.lang.ClassCastExeption
    Any help would be greatly appreciated.
    Thanks

    The value return by the getAtribute might not be of type String. If you want to return a String value you need to convert the value using the toString method as follow:
    <jbo:Row id="privRow" action="CURRENT" datasource="ds"/>
    <%
    String privName = "";
    Object obj = privRow.getAttribute("ArBau325");
    if (obj != null)
    privName = obj.toString();
    %>
    Also note that you do not need to put the scriplet code inside the body of the row tag.
    Charles.

  • Pass parameters to custom application from launchpad

    Hi!
    I have custom WD-application which is launched from "Related links" menu in standard application (bid, srm 7.0).
    I've added my item the menu with LPD_CUST transaction, but it is not clear how to pass some parameter to the application being launched.

    Hi,
    Have you created that guide?
    can you share it?

Maybe you are looking for