Custom Tag Authentication

Hello Everyone,
Quick question. If I want to redirect a user to a login.html page if they're not logged on and they are trying to use a resource, what is the best way to go about it? Should I page the bean value attribute to the tag and then just embed boolean values in the page with the pageContext.setAttribute(..)? Or is there a better way to go about it, since I'm just not sure with the way that the tag returns values (SKIP, etc.).
Thanks a lot,
Lior

If you have multiple filters, you can have your security one determine whether or not to continue with the chain or not. Code example:
chain.doFilter(request, response);
That continues in the chain of filters, if there are anymore. If you want to short circuit that and send the user somewhere else, simple don't call that method and either forward the user to another resource from the request object, or use a sendRedirect on the response object to send them to wherever.
EXample:
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                    throws java.io.IOException, ServletException
          if (something==true)
               // continue through other filters (if anymore)
               chain.doFilter(request, response);
          else
               // failed test, redirect (or forward) to another page/resource
               response.sendRedirect("/loginpage.jsp") ;
               return ;
     }

Similar Messages

  • Custom tag lib, tomcat server cant parse descripter file

    Hi there, I'm working on custom tag libraries, and I have created a simple tag which prints a string when it is called from a jsp file. And I have created a descriptor file for that perticular tag and also created a jsp file which is using the tab lib that I have created, I have placed all these files in their corresponding files, well the problem is when I'm trying to call that jsp file it says the server can't parse the tags.tld file, because <urn></urn> must be declared. And can anybody throw some light on this! it would be much of help from you side, regards, Raasi
    I have pasted all the files with the error message please have a look
    ************** Descriptor file ****************88
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
    <!-- a tag library descriptor -->
    <taglib>
         <!-- after this the default space is "http://java.sun.com/j2ee/dtds/jsptaglibrary_1_2.dtd" -->
         <tlibversion>1.0</tlibversion>
         <jspversion>1.1</jspversion>
         <shortname>csajsp</shortname>
         <urn></urn> <!-- problem is here. -->
         <info>
              A tag library from Core Servlets and JavaServer Pages, http://www.coreservlets.com/.
         </info>
         <tag>
              <name>example</name>
              <tagclass>coreservlets.tags.ExampleTag</tagclass>
              <info>Simplest example: inserts one line of output</info>
              <bodycontent>EMPTY</bodycontent>
         </tag>
         <!-- Other tags defined later... -->
    </taglib>
    The JSP file which is using that descriptor file
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <%@ taglib uri="csajsp-taglib.tld" prefix="csajsp" %>
    <TITLE><csajsp:example /></TITLE>
    <LINK REL=STYLESHEET HREF="JSP-Styles.css" TYPE="text/css">
    </HEAD>
    <BODY>
    <H1><csajsp:example /></H1>
    <csajsp:example />
    </BODY>
    </HTML>
    error message from Tomcat4.1 server
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: XML parsing error on file /jsp/csajsp-taglib.tld: (line 9, col 7): Element type "urn" must be declared.
         at org.apache.jasper.xmlparser.ParserUtils.parseXMLDocument(ParserUtils.java:189)
         at org.apache.jasper.compiler.TagLibraryInfoImpl.parseTLD(TagLibraryInfoImpl.java:247)
         at org.apache.jasper.compiler.TagLibraryInfoImpl.(TagLibraryInfoImpl.java:183)
         at org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:354)
         at org.apache.jasper.compiler.Parser.parseDirective(Parser.java:381)
         at org.apache.jasper.compiler.Parser.parseElements(Parser.java:799)
         at org.apache.jasper.compiler.Parser.parse(Parser.java:122)
         at org.apache.jasper.compiler.ParserController.parse(ParserController.java:199)
         at org.apache.jasper.compiler.ParserController.parse(ParserController.java:153)
         at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:219)
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:323)
         at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:289)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:260)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:471)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2396)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:405)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:380)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:508)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:533)
         at java.lang.Thread.run(Thread.java:536)
    Apache Tomcat/4.1.12
    ********************************8

    Hi,
    I have used the following dtd file for a simple tag you can use it by just replacing the tag properties
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE taglib
    PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
    "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_2.dtd">
    <taglib>
         <tlib-version>1.0</tlib-version>
         <jsp-version>1.2</jsp-version>
         <short-name>CooperatingTags</short-name>
         <description>
         </description>
         <tag>
              <name>first</name>
              <tag-class>com.opera.tagclasses.FirstTag</tag-class>
              <body-content>EMPTY</body-content>
              <attribute>
                   <name>sessionID</name>
                   <required>false</required>
                   <rtexprvalue>true</rtexprvalue>
              </attribute>
         </tag>
    </taglib>
    I guess tag urn is not required.
    Hope this helps
    Ravi

  • JSP Custom tag issues.

    Hi all,
    When my JAVA_HOME env variable is pointing to C:\jdk1.3, the JSP below which contains some custom tags fails to compile in Weblogic 5.1. However, when i change my JAVA_HOME env variable to C:\weblogic\jre1_2\jre, the same JSP compiles and deploys with no problems. I was of the opinion that the jre in jdk 1.3 is the same as jre1_2 which is bundled with weblogic 5.1. Does anyone know of any differences btw the Jre's or why the JSP below cannot be compiled when i use JDK1.3. Thanks for the help.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@ page import="java.util.Vector" %>
    <%@ page import="com.spcs.premiere.common.framework.errorhandling.ErrorUtility" %>
    <%@ page import="com.spcs.premiere.common.framework.errorhandling.PremiereLogger" %>
    <%@ page import="org.grnds.structural.web.GrndsServletException" %>
    <%@ taglib uri="/tlds/profiling/profile.tld" prefix="profile" %>
    <%@ page import="com.spcs.premiere.web.common.HTMLListBuilder" %>
    <%@ page import="com.spcs.premiere.web.common.ListParametersDomain" %>
    <%@ page import="com.spcs.premiere.web.common.PremiereConstants" %>
    <%@ page import="com.spcs.premiere.ejb.authentication.LoginDomain" %>
    <html>
    <head>
         <title>Premiere Business...Assign Credit Class</title>
         <LINK HREF="<%= request.getContextPath()%>/stylesheets/premiere.css" REL="stylesheet" TYPE="text/css">
         <SCRIPT LANGUAGE="javascript">
              var winHandle=window.dialogArguments;
         function userFocus()
              window.document.SupervisorLoginForm.SupervisorUserName.focus();
         </SCRIPT>
    </head>
    <body onload="userFocus();">
    <%
    try{
    %>
    <TABLE WIDTH="100%" HEIGHT="100%" CLASS="groupbox">
    <TR>
              <TABLE WIDTH="100%" HEIGHT="75%" CLASS="groupbox">
              <TR HEIGHT="15%"></TR>
              <FORM NAME="SupervisorLoginForm" ACTION="<%= request.getContextPath() %>/Premiere/AddAccountConversation/SupervisorLogin" METHOD="post" TARGET="_self">
    <TR HEIGHT="15%">
    <TD align=center><LABEL NAME="SupervisorUserNameLabel">User ID:</LABEL></TD></TD>
    <TD align=left><INPUT TYPE="text" NAME="SupervisorUserName" MAXLENGTH="20" SIZE="20" TABINDEX="1"></TD></TR>
              </TR>
              <TR>
    <TD align=center>    <LABEL NAME="SupervisorPasswordLabel">Password:</LABEL></TD></TD>
    <TD align=left><INPUT TYPE="password" NAME="SupervisorPassword" TABINDEX="2" MAXLENGTH="20" SIZE="20" ENABLED></TD>
              </TR>
              <TR>
              <TD COLSPAN="2" ALIGN="center"><BUTTON TYPE="submit" NAME="Login" TABINDEX="3" Class="button">Login</BUTTON></TD>
              <TD></TD>
              </TR></FORM>
              <FORM NAME="CreditClassForm" ACTION="<%= request.getContextPath() %>/Premiere/AddAccountConversation/AssignCreditManually" METHOD="post">
    <TR HEIGHT="60%">
    <TD align=center>        <LABEL NAME="SupervisorCreditClassLabel">Credit Class:</LABEL></TD></TD>
    <TD align=left>
              <profile:user WidgetName="CreditClass" Context="JSP" SubContext="SupervisorLogin" Evaluate="SUPERVISOR">
              <%= HTMLListBuilder.buildHTMLList((ListParametersDomain)session.getAttribute("CreditClassCodes")) %></TD>
              </profile:user>
              <TD></TD>          
              </TR>
              <TR></TR>
              </TR></TBODY></TABLE>
    </TR>
              <TR>
              <TABLE WIDTH="100%" HEIGHT="25%" CLASS="groupbox">
              <TD></TD>
              <TD align=right><BUTTON NAME="Cancel" Class="button" TABINDEX="4" ONCLICK="window.close()">Cancel</BUTTON>  
              <profile:user WidgetName="Save" Context="JSP" SubContext="SupervisorLogin" Evaluate="SUPERVISOR">
                   <BUTTON TYPE="submit" NAME="Save" TABINDEX="6" Class="button">Save</BUTTON>  
                   </profile:user>
              </TD>
              </TR></TBODY></TABLE>
              </TR></TBODY></TABLE>
              </FORM>
    <%
    catch (Exception e)
    LoginDomain loginDomain = (LoginDomain)session.getAttribute(PremiereConstants.LOGIN_DOMAIN);
    PremiereLogger.log( "ERROR", loginDomain.getUserName()+" General Exception Error: ", e );
    request.setAttribute(ErrorUtility.ERROR_CONDITION, ErrorUtility.getMessage(PremiereConstants.GENERIC_JSP_EXCEPTION_ERROR_ID) );
    throw new GrndsServletException();
    %>          
    </body>
    </html>

    UUh, interesting.
    Try to use the last Service Pack for 5.1 - i think it is sp9.
    Hope it'll work. I've had some problems with XML parsing but they resolved when I installed the last SP...

  • Challenge: how to login a user from a custom Tag?

    Hey. The question is in the title.
    This is the doEndTag() function inside a TagSupport implentation class :
    public int doEndTag() {
      String j_username = pageContext.getRequest().getParameter("j_username");
      String j_password = pageContext.getRequest().getParameter("j_password");
      // HOW TO USE THESE 2 STRINGS FOR LOGING THE USER?
      return EVAL_PAGE;
    }I can do basic authenticaton (I'm using tomcat btw), it's fine but I need to do this because the client is a Flash and not an html page. Any help is welcome, thanks!

    maybe spit out some javascript which sets hidden variables j_username and j_password on the page and submits to /j_security_check?
    The important thing is that the special URL /j_security_check is what handles the authentication, and that's handled by the Web Container. Unless you can exactly duplicate what the Web Container is doing in your custom tag, it's probably best to stick with the standard authentication, or roll your own.
    Brian

  • Trying to get AuthenticationUser from custom tag

    Hello, I'm trying to access the authentication username from a custom tag. The code we're using is this:
    IPTSession session = (IPTSession)GetEnvironment().GetUserSession();
    String authName = session.GetUser().GetAuthenticationUser();
    But we get an exception:
    com.plumtree.server.marshalers.PTException: -2147024891 - Error in function PTUser.GetAuthenticationUser (): -2147024891 - PLUMTREE authentication in use. AuthUser is user name.
    What does this mean? Does anyone know how else to approach this?

    Are you trying to get login name or definition of the user present in user repository ?
    Check these methods: GetUniqueAuthName() or GetLoginName().

  • Composing mail from email web application using jsp and custom tags

    here is the send.jsp file
    <%@ page language="java" %>
    <%@ page errorPage="errorpage.jsp" %>
    <%@ taglib uri="http://java.sun.com/products/javamail/demo/webapp"
    prefix="javamail" %>
    <html>
    <head>
         <title>JavaMail send</title>
    </head>
    <body bgcolor="white">
    hi
    <javamail:sendmail
    recipients="<%= request.getParameter(\"to\") %>"
    sender="<%= request.getParameter(\"from\") %>"
    subject="<%= request.getParameter(\"subject\") %>">
    <%= request.getParameter("text") %>
    </javamail:sendmail>
    <h1>Message sent successfully</h1>
    </body>
    </html>
    Here is the java file i.e used to refer to this custom tag
    package taglib;
    import java.util.*;
    import java.net.*;
    import javax.mail.*;
    import javax.mail.Authenticator;
    import javax.mail.internet.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * Custom tag for sending messages.
    public class SendTag extends BodyTagSupport {
    private String body;
    private String cc;
    private String host;
    private String recipients;
    private String sender;
    private String subject;
    * host attribute setter method.
    public void setHost(String host) {
    this.host = host;
    System.out.println("Host is : " +host);
    * recipient attribute setter method.
    public void setRecipients(String recipients) {
    this.recipients = recipients;
    System.out.println("recipients is " +recipients );
    * sender attribute setter method.
    public void setSender(String sender) {
    this.sender = sender;
    System.out.println("Sender is : " +sender);
    * cc attribute setter method.
    public void setCc(String cc) {
    this.cc = cc;
    * subject attribute setter method.
    public void setSubject(String subject) {
    this.subject = subject;
    System.out.println("subject is : " +subject);
    * Method for processing the end of the tag.
    public int doEndTag() throws JspException {
         System.out.println(" ** In do end tag");
    Properties props = System.getProperties();
    try {
    if (host != null)
    props.put("mail.smtp.host", host);
    else if (props.getProperty("mail.smtp.host") == null)
    props.put("mail.smtp.host", InetAddress.getLocalHost().
    getHostName());
    } catch (Exception ex) {
    throw new JspException(ex.getMessage());
    Session session = Session.getDefaultInstance(props,null);
         Message msg = new MimeMessage(session);
         InternetAddress[] toAddrs = null, ccAddrs = null;
    try {
         if (recipients != null) {
         toAddrs = InternetAddress.parse(recipients, false);
         msg.setRecipients(Message.RecipientType.TO, toAddrs);
         } else
         throw new JspException("No recipient address specified");
    if (sender != null)
    msg.setFrom(new InternetAddress(sender));
    else
    throw new JspException("No sender address specified");
         if (cc != null) {
    ccAddrs = InternetAddress.parse(cc, false);
         msg.setRecipients(Message.RecipientType.CC, ccAddrs);
         if (subject != null)
         msg.setSubject(subject);
         if ((body = getBodyContent().getString()) != null)
         msg.setText(body);
    else
    msg.setText("");
    Transport.send(msg);
    } catch (Exception ex) {
    throw new JspException(ex.getMessage());
    return(EVAL_PAGE);
    all the entries in taglib.tld and web.xml are correct.
    It is one of the article given at this url:
    http://java.sun.com/developer/technicalArticles/javaserverpages/emailapps/

    First, you should not take copyrighted code and post it without a copyright.
    The code you posted is copyright Sun Microsystems.
    Second, why did you post it? Did you have a question?

  • Why doesn't my custom tag work?

    First, my backend database is MS Access. Nothing I can do about that, unfortunately.
    I have defined three custom tags (no body, no attributes) to display report information from my project tracking/metrics Access database:
    <prefix:showProjectInfo />
    <prefix:showProjectTeam />
    <prefix:showProjectHistory />
    In my JSP, the first tag I use, <prefix:showProjectInfo />, works perfectly. However, <prefix:showProjectTeam /> gives no output.
    First, here is the tld file that defines the tags (report.tld):
    <?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>report</short-name>
        <uri>/report</uri>   
        <!-- Forte4J_TLDX:  This comment contains code generation information. Do not delete.
        <tldx>
            <tagHandlerGenerationRoot>classes</tagHandlerGenerationRoot>
        </tldx>
        -->
        <!-- A validator verifies that the tags are used correctly at JSP
             translation time. Validator entries look like this:
          <validator>
              <validator-class>com.mycompany.TagLibValidator</validator-class>
              <init-param>
                 <param-name>parameter</param-name>
                 <param-value>value</param-value>
           </init-param>
          </validator>
       -->
       <!-- A tag library can register Servlet Context event listeners in
            case it needs to react to such events. Listener entries look
            like this:
         <listener>
             <listener-class>com.mycompany.TagLibListener</listener-class>
         </listener>
       -->
       <tag>
            <name>showProjectInfo</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectInfoTag</tag-class>
            <body-content>empty</body-content>
            <description>Shows the basic project information</description>       
       </tag>
       <tag>
            <name>showProjectTeam</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectTeamTag</tag-class>
            <body-content>empty</body-content>
       </tag>
       <tag>
            <name>showProjectHistory</name>
            <tag-class>mil.usaf.rad.metrics.report.showProjectHistoryTag</tag-class>
            <body-content>empty</body-content>
       </tag>
    </taglib>Next, here is the relevant section of web.xml that defines this taglib:
      <taglib>
            <taglib-uri>/WEB-INF/report.tld</taglib-uri>
            <taglib-location>/WEB-INF/report.tld</taglib-location>
      </taglib>Next, the code for showProjectTeamTag.java:
    * showProjectTeam.java
    * Created on March 9, 2005, 10:46 AM
    package mil.usaf.rad.metrics.report;
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectTeamTag extends TagSupport
        public showProjectTeamTag()
            super();
        public int doAfterBody() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               out.print("test");
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
               conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryGetTeam = "SELECT Projects.pr_id, Accounts.name AS Name, Sum(Schedule.hours) AS SumOfhours FROM tblTAAccounts AS Accounts INNER JOIN ((tblTAScheduleEntries AS Schedule INNER JOIN tblProjectRelease AS ProjectRelease ON Schedule.projectID = ProjectRelease.tblFKTimeAccntProject) INNER JOIN tblPMProjects AS Projects ON ProjectRelease.Release_ID = Projects.pr_id) ON Accounts.accountID = Schedule.accountID WHERE Projects.pr_id=" + pr_id + " GROUP BY Projects.pr_id, Accounts.name, ProjectRelease.Release_number, Projects.Project_name";
            try
                out.print(queryGetTeam);
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryGetTeam);
                if (rs == null)
                    out.print("No Results!");
                out.print("<table>\n");
                out.print("<tr>\n");
                out.print("<th>Name</th>\n");
                out.print("<th>Total Hours</th>\n");
                out.print("</tr>\n");
                while(rs.next())
                    out.print("<tr>\n");
                    out.print("<td>" + rs.getString("Name") + "</td>\n");
                    out.print("<td>" + rs.getInt("SumOfhours") + "</td>\n");
                    out.print("</tr>\n");
                out.print("</table>\n");
                rs.close();
                stmt.close();
                conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            return SKIP_BODY;
    }Finally, projectdetail.jsp, where the tag is called:
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <%@page import="java.sql.*" %>
    <%@page import="java.lang.Integer" %>
    <%@taglib uri="/WEB-INF/report.tld" prefix="report" %>
    <html>
    <head><title>Project Detail</title></head>
    <body>
    <h1 align="center">Project Status</h1>
    <h3>Project Description</h3>
    <report:showProjectInfo />
    <h3>Team Members</h3>
    <report:showProjectTeam />
    </body>
    </html>The first tag, <report:showProjectInfo />, works fine. However, I get no output whatsoever when the system encounters <report:showProjectTeam />. I am a relative newbie at this, so any help is appreciated.
    Jason

    It doesnt seem to matter if the code is in doStartTag(), doEndTag(), orr any of the other functions.
    I also put, as the first item in the function:
    System.out.println("TEST");Nothing.
    Just as an aside, here is the code for the <prefix:showProjectInfo />. Maybe I made a mistake in it? I closed the resultset and connection...
    import java.io.*;
    import java.sql.*;
    import java.lang.Integer;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    import javax.servlet.jsp.tagext.*;
    * @author  jason.ferguson
    public class showProjectInfoTag extends BodyTagSupport
        public int doEndTag() throws JspException
            HttpServletRequest req = (HttpServletRequest) pageContext.getRequest();
            int pr_id = Integer.parseInt(req.getParameter("pr_id"));
            JspWriter out = pageContext.getOut();
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            try
               Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                conn = DriverManager.getConnection("jdbc:odbc:Metrics");
            catch (Exception e)
                throw new JspException(e.getMessage());
            String queryProjectInfo = "SELECT * FROM tblPMProjects WHERE pr_id=" + pr_id;
            try
                stmt = conn.createStatement();
                rs = stmt.executeQuery(queryProjectInfo);
                while (rs.next())
                    out.print("<table border=\"1\" style=\"border-collapse:collapse\">\n");
                    out.print("<tr>\n");
                    out.print("<td><b>Project Name:</b>" + rs.getString("Project_name") + "</td>\n");
                    out.print("<td align=\"right\"><b>RAD Number:</b>" + rs.getString("tblProjectNumber") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Project description: " + rs.getString("Project_description") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer: " + rs.getString("Customer_POC") + "</td>");
                    out.print("<tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Unit: " + rs.getString("Customer_OFC") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("<tr>\n");
                    out.print("<td>Customer Phone: " + rs.getString("Customer_phone") + "</td>\n");
                    out.print("</tr>\n");
                    out.print("</table>\n");
                    rs.close();
                    stmt.close();
                    conn.close();
            catch (Exception e)
                throw new JspException(e.getMessage());
            finally
                //conn.close();
            return SKIP_BODY;

  • Weblogic Commerce Server 3.5 runtime failure in custom tag

    An error occurred:
    javax.servlet.ServletException: runtime failure in custom tag 'process'
         at jsp_compiled._tools._property._propset_create._jspService(_propset_create.java:641)
         at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
         at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:149)
         at com.beasys.commerce.foundation.flow.ServletDestinationHandler.handleDestination(ServletDestinationHandler.java:51)
         at com.beasys.commerce.foundation.flow.FlowManager.service(FlowManager.java:540)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:208)
         at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:1127)
         at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:1529)
         at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:137)
         at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:120)

    I just started getting this error after a year in production environment without any problems. Did you every find out what caused this or better yet how to prevent this?
              Dan.
              

  • 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

  • Is possible to write a custom tag inside another custom tag ??

    Hi
    I�m trying to reduce the time needed to code mi app presentation layer, it uses some custom tags with certain configuration, i would like to know if its possible to do something like this inside my custom tag doAfterBody().
    public int doAfterBody() throws JspException {
              JspWriter writer=bodyContent.getEnclosingWriter();
              try {
                   writer.print("<customTag:myAnotherTag someEspecificConfigurationParams="someEspecificValues"/>");
              } catch (IOException e) {
                   pageContext.getServletContext().log("Error: "+e.getMessage());
              }return SKIP_BODY;
         }The goal is to simplify the jsp code because the configuration params for the custom tags (css styles and similar) are allways the same.
    That don�t work, it simply prints <customTag:myAnotherTag/> in screen but the tag is not evaluated, i�ve tried too something like
    public int doAfterBody() throws JspException {
              if (repeat) {
                   JspWriter writer = bodyContent.getEnclosingWriter();
                   try {
                        writer.print("<customTag:myAnotherTag/>");
                   } catch (IOException e) {
                        pageContext.getServletContext().log("Error: " + e.getMessage());
                   repeat = false;
                   return EVAL_BODY_AGAIN;
              return SKIP_BODY;
         }And it doesn�t worked worked. Maybe using the taghandler classes and calls to the doAfterBody could make it work, but when you need to nest tags it could be a little hell of coupling calls, so before doing it i would like to know if what i want is possible. After reading some books i tought it could work because the stack of out objects, but i can�t make it work.
    Another idea is to inherit from tagHandler and override some properties in the tags, but i don�t like the idea to much.
    So, can anyone help me??
    Thanks.

    You cannot do that and I have listed out the reason and a possible solution in this post http://forum.java.sun.com/thread.jspa?threadID=697243 from yesterday.
    cheers,
    ram.

  • How to prepare Custom tag with scope as  session  like Struts tag

    Hi
    All Struts tags having the feature of Automatic Scoping.
    Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
    same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
    regards
    jagan

    Hi
    All Struts tags having the feature of Automatic Scoping.
    Automatic Scoping: Struts tags check all contexts (namely page, request, session, application) and use the first instance found. Developers do not have to explicitly "retrieve" objects from a particular scope. They may, however, specify a context.
    same as like struts tag I want to preapre 'select custom tag'.which will retrieve its previous selected value automatically and display.And one important thing is I dont want to set the selected value of custom tag in session expicitly.I mean the custom tag it self should take care to set the session vale and retrieve the sesion value and display like Struts tag . For struts select tag we wont set any selected value in session though it will retrieve the previous value and display when scope of form = session
    regards
    jagan

  • Make new custom tag in A2

    Good evening,
    I'm trying to add a custom tag to an image in Aperture 2.0. I've looked all over the internet and find no examples what so ever of AS and Aperture 2.0.
    I have a few guesses that produce one of two different errors - but no idea how to actually make this work. Any ideas ?
    tell application "Aperture"
    copy selection to theSel
    repeat with curImg in theSel
    class of curImg
    --image version
    -- make new custom tag at curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- set aNewTag to make new custom tag with properties {name:"NewTag", value:"New Tag's Value"}
    -- Aperture got an error: Can’t make or move that element into that container.
    -- make new custom tag at end of curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of (curImg) with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of custom tags of curImg with properties {name:"NewTag", value:"New Tag's Value"}
    -- make new custom tag at end of curImg's custom tags with properties {name:"NewTag", value:"New Tag's Value"}
    --Aperture got an error: Can’t make application "Aperture" into type specifier.
    end repeat
    end tell

    If I recall, it was done because how tags were to be handled in 1.2 was very different from 1.1 and it was felt that developers shouldn't rely on implementation specific classes (unless they were SPI) for several other reasons (application portability being the big one here).
    If it's felt that this was the wrong decision, please feel free to log an issue [1] against the RI (to date, no one has).
    As to the 'borked' dependency URLs, please log an issue [1] if you find these. We have nightly builds going that work from a clean workspace and checking today's result, it seems ok.
    [1] https://javaserverfaces.dev.java.net/issues

  • Passing Javascript Enabled or Disabled value in a custom tag

    Hi,
    In my JSP I am using a custom tag.
    This custom tag is having one attribute called status(whose value will be jsenabled means true or jsdisabled means false) depending on the browser's javascript enabled or disabled
    How can i find the value of javascript enabled or javascript disabled and set the value of the attribute status in my jsp.
    This is the custom tag
    <t:tab summary="tabs" url="/services/eservicepac/registrationprocess/process.wss" tabNames='<%=tabList%>' currentTab="<%=currentTab%>" zone="WWW_ZONE" fetchText="false" status=" "
    </t:tab>
    The value of this attribute status=" " should be the value of jsenabled or disabled.
    Since the user can visit any page at any time, the jsenabled value is not maintained in session or request, so i can't take from session or request also.
    As this is urgent,
    --I am expecting the reply                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi Merlin,
    In addition to what was written above, you must make sure that you tell your web application to run as a JSP 2.0 web application.
    You do this by defining your web.xml a little differently. Like this at the top:
    <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_2_4.xsd">
    That should be what you need to get it working correctly.
    Damian Sutton

  • How to create a custom tag for a custom converter

    In Jdeveloper 11g, I have a project where I have created a custom converter class that impements the javax.faces.convert.Converter class. I have registered the converter with an id in the faces-config.xml file of the project, and the converter works fine by using the <f:converter type="myconverter"> tag. However, the custom converter has a field which I would like to set from the tag itself. Hence, I would like to add an attribute to <f:converter> tag if possible or create a custom tag that has the attribute.
    I have done some reserach and I found that a custom tag can be implemented: I need to create a class which extends from the ConverterTag class or javax.faces.webapp.ConverterElTag class, which I did, but I also need to create ".tld" (tag library) file which defines the tag itself.
    The part about creating the ".tld" file and registring the new tag is what I'm not sure how to do.
    Does someone know how to do this?
    thank you

    Hi frank,
    that's a good document, and it explains how to make a custom converter. I already created the custom converter, it converts a number to any currency pattern. I know java already has a currency converter, but it doesn't support Rupee currency format, and I need that format.
    My converter works, but I would like to pass the pattern of the format through an attribute in a tag. Since f:converter doesn't seem to support that, I created a custom tag which uses my converter, and it enables me to pass a pattern to the converter.
    All of that works, but I need to be able to pass the pattern as an EL expression, and it's not evaluating the expression before passing it to the converter. It just passes the whole expression as a string. I'm thinking It may be something I'm doing wrong.
    this is the tag library definition file:
    <!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.2</tlib-version>
    <jsp-version>2.1</jsp-version>
    <short-name>custom</short-name>
    <uri>custom-currency-converter</uri>
    <description>
    custom currency custom tag library
    </description>
    <tag>
    <name>CurrencyConverter</name>
    <tag-class>
    converter.Tag.CurrencyConverterTag
    </tag-class>
    <body-content>JSP</body-content>
    <attribute>
    <name>pattern</name>
    <type>java.util.String</type>
    <required>true</required>
    <rtexprvalue>true</rtexprvalue>
    </attribute>
    </tag>
    </taglib>
    Edited by: Abraham Ciokler on Feb 4, 2011 11:20 AM

  • How To create a custom tag in jsf

    I'm trying to create a custom tag in jsf.what should be the approach to create it.it would be better if somebody will explain me from the skretch.

    There's a decent tutorial here, Priyo:
    http://www.exadel.com/tutorial/jsf/HowToWriteYourOwnJSFComponents.pdf
    Hope it helps,
    Illu

Maybe you are looking for

  • Apple iTunes Store vanishing in iTunes 9.1.1 in Windows 7 (64bit)

    I have iTunes 9.1.1 installed and everything is fine except when I try to access "iTunes Store" I get "Accessing iTunes Store" (with the stripey progress bar) then it fleetingly (for a fraction of a second) displays thee Apple iTunes Store, but then

  • Content in PL/SQL block

    I am new to PL/SQL. I understand that I can run PL/SQL from sqlplus. But it does not work for me if I put sqlplus command in PL/SQL blocks. For example: BEGIN IF &1 IS NULL THEN CONNECT username/userpassword ELSE CONNECT username/userpassword@&1 ENDI

  • SDK sample code for Changing name of Exported file thru Webi schedule

    Hi experts, I am wanting to know if someone has got any sample Java SDK code which I can use to login to FTP and rename the pdf files generated from webi schedule script and append customised date format towards the end.

  • Bonus points for pre-ordering X-Men: Days of Future Past

    Hello, I ordered this blu-ray the same day as I did for Captain America: The Winter's Soldier.  I received my 100 bonus points for Captain America a few weeks ago.  However, when I checked my account this morning for the bonus points on X-Men, it onl

  • Acces to JNDI with a servlet

    Hi,           I'm beginner with Java and Weblogic.           I've write an EJB, with a client classe wich works properly.           When I want to call this client from a servlet (using the same method), I           have this error :           java.l