You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Roland Dong <rd...@cait.org> on 2003/06/16 20:59:40 UTC

Auto commit in Jakarta taglib?


I have some programs which uses pre-jstl jakarta taglib.  I want to have the
query commit only if there is no errors. However, I could not find in tags
for setting "autocommit".

Tried to add <%conn.setAutoCommit(false);%> but that doesn't work. So I am
wondering if there is a workaround other than rewriting everything using
other tag library(I know struts has it).

Thanks in advance.

RD


The is a code example I used to test auto commit.

=============================
<%-- Taglib Directives --%>
<%@taglib uri="http://database.cait.org/dbtags" prefix="sql"   %>

<-database connection--%>
<%@ include file="../includes/dbConnection.jsp"%>


<sql:statement id="stmt" conn="conn">


      
          <sql:query>
             INSERT INTO school
             VALUES (
                       '666',
                       'rd',
                       'street1',
                       'city1',
                       'county1',
                       'state1',
                       'zip1',
                       'phone1'
                      )
          </sql:query>
          <sql:execute />
       
        <sql:query>
             INSERT INTO school1
             VALUES (
                       '888',
                       'rd',
                       'street1',
                       'city1',
                       'county1',
                       'state1',
                       'zip1',
                       'phone1'
                      )
          </sql:query>
          <sql:execute />
       
     </sql:statement>
      
      OK! 
     <%-- Close database connection --%>
<sql:closeConnection conn="conn"/>
===================================
             


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Exception var - how to get using JSTL

Posted by Michael Duffy <du...@yahoo.com>.
Yes, 'javax.servlet.jsp.jspException' is the parameter
name that's used when the exception value is set. 
It's important to know, because if you do MVC-2 with
your own front controller servlet you've got to set
that parameter inside the servlet whenever an
exception is thrown.  If you don't, the JSP error page
won't find it.

Buy Shawn Bayern's "JSTL In Action" book by Manning. 
What you wanted was right there on page 267.  Lots of
other good stuff, too.

Anytime I'm faced with a new technology I like to have
a good book at my elbow.  When I started with JSTL,
this was the only book I bought.

--- Jim Kennedy <ji...@gigaheads.com> wrote:
> This also works:
> <c:set var="error"
>
value="${requestScope['javax.servlet.jsp.jspException']}"
> /> (for Tomcat)
> 
> but I wanted to avoid the "javax.servlet.jsp..."
> stuff.
> 
> Your method is what I was looking for.  I have not
> read anything that lead
> me to "exception" being the name of that property. 
> Is there a table that
> shows all available pageContext properties.  It's
> definitely logical though
> since exception is an implicit variable for JSP
> pages.  However, that
> pattern breaks down for:
> 
> pageContext.servletConfig  which is "config" in JSP
> pages
> 
> and
> 
> pageContext.servletContext which is "application" in
> JSP pages.
> 
> Can you tell me how you came by this info for
> "exception".
> 
> 
> 
> thanks
> 
> 
> Jim Kennedy
> IT Consultant
> Mobile Phone: 813-503-1484
>
-----------------------------------------------------
> 
> 
> 
> ----- Original Message -----
> From: "Michael Duffy" <du...@yahoo.com>
> To: "Tag Libraries Users List"
> <ta...@jakarta.apache.org>; "Jim
> Kennedy" <jg...@mindspring.com>
> Sent: Tuesday, June 17, 2003 4:39 PM
> Subject: Re: Exception var - how to get using JSTL
> 
> 
> >
> > Wouldn't you use
> >
> > <c:out value="${pageContext.exception.message}"/>?
> >
> > That's just straight JSTL, so it should be okay. -
> MOD
> >
> >
> >
> > --- Jim Kennedy <ji...@gigaheads.com> wrote:
> > > Can someone help me with the technique to grap
> the
> > > exception (implicit)
> > > variable that exists when isErrorPage=true.  I
> know
> > > it will be part of the
> > > pageScope JSTL variable, but I need a technique
> NOT
> > > specific to a container.
> > >
> > > I don't want to use <% %> at all.  I need an
> only
> > > tag technique.
> > >
> > > Currently there is not ${exception} guy.
> > >
> > > Thanks
> > >
> > >
> > >
> >
>
---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > > taglibs-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail:
> > > taglibs-user-help@jakarta.apache.org
> > >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > SBC Yahoo! DSL - Now only $29.95 per month!
> > http://sbc.yahoo.com
> >
> >
>
---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> taglibs-user-help@jakarta.apache.org
> >
> >
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> taglibs-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Exception var - how to get using JSTL

Posted by Jim Kennedy <ji...@gigaheads.com>.
This also works:
<c:set var="error" value="${requestScope['javax.servlet.jsp.jspException']}"
/> (for Tomcat)

but I wanted to avoid the "javax.servlet.jsp..." stuff.

Your method is what I was looking for.  I have not read anything that lead
me to "exception" being the name of that property.  Is there a table that
shows all available pageContext properties.  It's definitely logical though
since exception is an implicit variable for JSP pages.  However, that
pattern breaks down for:

pageContext.servletConfig  which is "config" in JSP pages

and

pageContext.servletContext which is "application" in JSP pages.

Can you tell me how you came by this info for "exception".



thanks


Jim Kennedy
IT Consultant
Mobile Phone: 813-503-1484
-----------------------------------------------------



----- Original Message -----
From: "Michael Duffy" <du...@yahoo.com>
To: "Tag Libraries Users List" <ta...@jakarta.apache.org>; "Jim
Kennedy" <jg...@mindspring.com>
Sent: Tuesday, June 17, 2003 4:39 PM
Subject: Re: Exception var - how to get using JSTL


>
> Wouldn't you use
>
> <c:out value="${pageContext.exception.message}"/>?
>
> That's just straight JSTL, so it should be okay. - MOD
>
>
>
> --- Jim Kennedy <ji...@gigaheads.com> wrote:
> > Can someone help me with the technique to grap the
> > exception (implicit)
> > variable that exists when isErrorPage=true.  I know
> > it will be part of the
> > pageScope JSTL variable, but I need a technique NOT
> > specific to a container.
> >
> > I don't want to use <% %> at all.  I need an only
> > tag technique.
> >
> > Currently there is not ${exception} guy.
> >
> > Thanks
> >
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > taglibs-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail:
> > taglibs-user-help@jakarta.apache.org
> >
>
>
> __________________________________
> Do you Yahoo!?
> SBC Yahoo! DSL - Now only $29.95 per month!
> http://sbc.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Exception var - how to get using JSTL

Posted by Michael Duffy <du...@yahoo.com>.
Wouldn't you use

<c:out value="${pageContext.exception.message}"/>?  

That's just straight JSTL, so it should be okay. - MOD



--- Jim Kennedy <ji...@gigaheads.com> wrote:
> Can someone help me with the technique to grap the
> exception (implicit)
> variable that exists when isErrorPage=true.  I know
> it will be part of the
> pageScope JSTL variable, but I need a technique NOT
> specific to a container.
> 
> I don't want to use <% %> at all.  I need an only
> tag technique.
> 
> Currently there is not ${exception} guy.
> 
> Thanks
> 
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail:
> taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail:
> taglibs-user-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Exception var - how to get using JSTL

Posted by Jim Kennedy <ji...@gigaheads.com>.
Can someone help me with the technique to grap the exception (implicit)
variable that exists when isErrorPage=true.  I know it will be part of the
pageScope JSTL variable, but I need a technique NOT specific to a container.

I don't want to use <% %> at all.  I need an only tag technique.

Currently there is not ${exception} guy.

Thanks


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Auto commit in Jakarta taglib?

Posted by Roland Dong <rd...@cait.org>.
Shawn,

Thanks for your reply.  Unfortunately our company still uses iPlanet 6 which
is not supporting JSP1.2.

Thanks again,

RD



On 6/16/03 2:18 PM, "Shawn Bayern" <ba...@essentially.net> wrote:

> Ah - I just realized you were using DBTags, not JSTL.  If you're using a
> JSP 1.2 container, you'll probably want to switch to JSTL anyway.

-- 



---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Auto commit in Jakarta taglib?

Posted by Shawn Bayern <ba...@essentially.net>.
Ah - I just realized you were using DBTags, not JSTL.  If you're using a
JSP 1.2 container, you'll probably want to switch to JSTL anyway.

-- 
Shawn Bayern
"JSTL in Action"   http://www.manning.com/bayern

On Mon, 16 Jun 2003, Roland Dong wrote:

> 
> 
> I have some programs which uses pre-jstl jakarta taglib.  I want to have the
> query commit only if there is no errors. However, I could not find in tags
> for setting "autocommit".
> 
> Tried to add <%conn.setAutoCommit(false);%> but that doesn't work. So I am
> wondering if there is a workaround other than rewriting everything using
> other tag library(I know struts has it).
> 
> Thanks in advance.
> 
> RD
> 
> 
> The is a code example I used to test auto commit.
> 
> =============================
> <%-- Taglib Directives --%>
> <%@taglib uri="http://database.cait.org/dbtags" prefix="sql"   %>
> 
> <-database connection--%>
> <%@ include file="../includes/dbConnection.jsp"%>
> 
> 
> <sql:statement id="stmt" conn="conn">
> 
> 
>       
>           <sql:query>
>              INSERT INTO school
>              VALUES (
>                        '666',
>                        'rd',
>                        'street1',
>                        'city1',
>                        'county1',
>                        'state1',
>                        'zip1',
>                        'phone1'
>                       )
>           </sql:query>
>           <sql:execute />
>        
>         <sql:query>
>              INSERT INTO school1
>              VALUES (
>                        '888',
>                        'rd',
>                        'street1',
>                        'city1',
>                        'county1',
>                        'state1',
>                        'zip1',
>                        'phone1'
>                       )
>           </sql:query>
>           <sql:execute />
>        
>      </sql:statement>
>       
>       OK! 
>      <%-- Close database connection --%>
> <sql:closeConnection conn="conn"/>
> ===================================
>              
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: Auto commit in Jakarta taglib?

Posted by Shawn Bayern <ba...@essentially.net>.
JSTL offers a <sql:transaction> tag to handle transactions; you can simply
group related <sql:update> tags -- which you should be using instead of
<sql:query> -- as children of a sql:transaction> element.

-- 
Shawn Bayern
"JSTL in Action"   http://www.manning.com/bayern

On Mon, 16 Jun 2003, Roland Dong wrote:

> 
> 
> I have some programs which uses pre-jstl jakarta taglib.  I want to have the
> query commit only if there is no errors. However, I could not find in tags
> for setting "autocommit".
> 
> Tried to add <%conn.setAutoCommit(false);%> but that doesn't work. So I am
> wondering if there is a workaround other than rewriting everything using
> other tag library(I know struts has it).
> 
> Thanks in advance.
> 
> RD
> 
> 
> The is a code example I used to test auto commit.
> 
> =============================
> <%-- Taglib Directives --%>
> <%@taglib uri="http://database.cait.org/dbtags" prefix="sql"   %>
> 
> <-database connection--%>
> <%@ include file="../includes/dbConnection.jsp"%>
> 
> 
> <sql:statement id="stmt" conn="conn">
> 
> 
>       
>           <sql:query>
>              INSERT INTO school
>              VALUES (
>                        '666',
>                        'rd',
>                        'street1',
>                        'city1',
>                        'county1',
>                        'state1',
>                        'zip1',
>                        'phone1'
>                       )
>           </sql:query>
>           <sql:execute />
>        
>         <sql:query>
>              INSERT INTO school1
>              VALUES (
>                        '888',
>                        'rd',
>                        'street1',
>                        'city1',
>                        'county1',
>                        'state1',
>                        'zip1',
>                        'phone1'
>                       )
>           </sql:query>
>           <sql:execute />
>        
>      </sql:statement>
>       
>       OK! 
>      <%-- Close database connection --%>
> <sql:closeConnection conn="conn"/>
> ===================================
>              
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org