How can i write jstl with jsp in sql:update ,when it give sqlException"

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<sql:query var="login" dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul">
SELECT * FROM login;
</sql:query>
<html>
<head>
<title>login information</title>
</head>
<body>
<h1>login information</h1>
<table border="1">
<tr>
<th>id</th>
<th>login</th>
<th colspan="2">password</th>
</tr>
<c:forEach var="round" items="${login.rows}" >
<tr>
<td>${round.id}</td>
<td>${round.login}</td>
<td colspan="2">${round.password}</td>
</tr>
</c:forEach><tr>
<form name="round-input" action="round_process.jsp" method="POST">
<td><input name="id" type="text" size="20" /></td>
<td><input name="login" type="text" size="20" /></td>
<td><input name="password" type="text" size="20" /></td>
<td><input type="submit" value="Update" /></td>
</form>
</tr>
</table>
</body>
</html>
it pass the parameter in round_process.jsp
<!--
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jstl/sql_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>
-->
<sql:query var="login" dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul">
SELECT * FROM login WHERE id=?
<sql:param value="${param.id}"/>
</sql:query>
<sql:update>
INSERT INTO login(id,login,password)VALUES(?,?,?)
<sql:param value="${param.id}"/>
<sql:param value="${param.login}"/>
<sql:param value="${param.password}"/>
</sql:update>
<c:redirect url="round-input.jsp"/>
when i execute the second .jsp page it will show an exception and error that is
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "null"
     org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
     org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
     org.apache.jsp.round_005fprocess_jsp._jspService(round_005fprocess_jsp.java:87)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "null"
     org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.getConnection(UpdateTagSupport.java:234)
     org.apache.taglibs.standard.tag.common.sql.UpdateTagSupport.doStartTag(UpdateTagSupport.java:115)
     org.apache.jsp.round_005fprocess_jsp._jspx_meth_sql_update_0(round_005fprocess_jsp.java:168)
     org.apache.jsp.round_005fprocess_jsp._jspService(round_005fprocess_jsp.java:71)
     org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
     org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
     org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
     org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
     javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
note The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.

Your problem is that you need to have a
<sql:setDataSource
       var="myDataSource"
       dataSource="jdbc:mysql://localhost/user,com.mysql.jdbc.Driver,user,parul"
/>and your sql:query would now be
<sql:query var="login" dataSource="${myDataSource}">
SELECT * FROM login;
</sql:query>You can use whatever name you want for the var in the setDataSource as long as it matches the dataSource in the query.

Similar Messages

  • HOW can I call EJB with JSP?

    Hi, I'm working with JSP and want to include some EJB. I dont know how can I access EJB through JSP. I dont know if I use the right code in JSP for calling EJB. Did someone know how to use that? Can someone tell me if is the right code in JSP in my example?
    Thanks, Kristjan
    THIS IS THE JSP: (useejb.jsp)
    <%@ taglib uri="http://xmlns.oracle.com/j2ee/jsp/tld/ojsp/ejbtaglib.tld" prefix="EJB" %>
    <%@ page import="mypackage1.MySessionEJB" %>
    <%@ page import="mypackage1.MySessionEJBHome" %>
    <%@ page import="mypackage1.impl.MySessionEJBBean" %>
    <HTML>
    <head><TITLE>USEBEAN</TITLE></head>
    <body>
    <EJB:useHome id="mySessionEJBHome" type="mypackage1.MySessionEJBHome" location="java:comp/env/ejb/mySessionEJB" local="false" />
    <EJB:useBean id="mySessionEJBBean" type="mypackage1.impl.MySessionEJBBean" local="false">
    <EJB:createBean instance="<%=mySessionEJBHome.create() %>" />
    </EJB:useBean>
    <%= mySessionEJBBean.calc() %>
    </body>
    </html>
    THIS IS THE EJB CODE:(MySessionEJBBean.java)
    package mypackage1.impl;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import java.lang.String.*;
    public class MySessionEJBBean implements SessionBean
    public void ejbCreate(){}
    public void ejbActivate(){}
    public void ejbPassivate(){}
    public void ejbRemove(){}
    public void setSessionContext(SessionContext ctx){}
    public String calc(String value)
    return value + value;
    public String zanka(String x)
    return x;
    (MySessionEJB.java)
    package mypackage1;
    import javax.ejb.EJBObject;
    import java.rmi.RemoteException;
    public interface MySessionEJB extends EJBObject
    public String calc(String value) throws RemoteException;
    String zanka(String x) throws RemoteException;
    (MySessionEJBHome.java)
    package mypackage1;
    import javax.ejb.EJBHome;
    import java.rmi.RemoteException;
    import javax.ejb.CreateException;
    public interface MySessionEJBHome extends EJBHome
    public MySessionEJB create() throws RemoteException, CreateException;
    }

    You might want to look at using a Java Bean wrapper, this can be done automically using WebSphere. It creates what is called an access bean which the JSP imports.
    HTH,
    J.Clancey

  • How can we write methods in Jsp ?

    I want to write methods in jsp in such a way that in one method I should have "Creating database connection" and in another method I want to create ResultSet and in another method I want to access the ResultSet.

    u can write methods in jsp using the following tag
    <%!
    public void myMethod()
    %>

  • R: (forte-users) How can I write numbers with 7 digit in aListView?

     

    here is the copy paste of PDF that I am working on:
    %PDF-1. 4
    1 0 obj
    << /Type /Catalog
    /Outlines 2 0 R
    /Pages 3 0 R
    >>
    endobj
    2 0 obj
    << /Type /Outlines
    /Count 0
    >>
    endobj
    3 0 obj
    << /Type /Pages
    /Kids
    /Count 1
    >>
    endobj
    4 0 obj
    << /Type /Page
    /Parent 3 0 R
    /MediaBox
    /Contents 5 0 R
    /Resources << /ProcSet 6 0 R >>
    >>
    endobj
    5 0 obj
    << /Length 883 >>
    stream
    %write text with size 14 helvetica font
    BT
    /F1 14 Tf
    145.417 347.529 Td
    ( This is text output ) Tj
    ET
    %draw line horizontal - with width 1
    0.5 w
    360 648 m
    144 648 l
    S
    %draw line vertical- with width 1
    0.5 w
    432 648 m
    432 504 l
    S
    %draw rectangle - with width 1
    0.5 w
    144 432 216 72 re
    S
    endstream
    endobj
    6 0 obj
    endobj
    q
    100 0 0 50 150 600 cm
    BI
       /W 5
       /H 5
       /BPC 8
       /CS /G
       /F /AHx
    ID
    0000000000
    FFFFFFFFFF
    0000000000
    FFFFFFFFFF
    0000000000
    EI
    Q
    xref
    0 7
    0000000000 65535 f
    0000000009 00000 n
    0000000074 00000 n
    0000000120 00000 n
    0000000179 00000 n
    0000000300 00000 n
    0000001532 00000 n
    trailer
    << /Size 7
    /Root 1 0 R
    >>
    startxref
    1556
    %%EOF

  • How can i do it with JSP -  dealing with multipart/form-data?

    Hi guys,
    i have a form in which one of its components is a optional file that can be uploaded to the server. Up here, no matter...
    I thought that i could evaluate the file size, so i would avoid upload process which size was bigger than something, like 10kBytes. Of course, i wouldnt like to do something like: post to servlet and then, dispatcher an error page. If the browser could stay with the same page( and form), it would be very good!
    Thanks in advance, Euclides.

    My doubt is: is there a
    way to evaluate the file size before posting it? Is it
    Javascript? Hard to do it? How?http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20765620.html
    scroll down about 1/2 down the page.
    -Rob

  • Re: (forte-users) How can I write numbers with 7 digit in aListView?

     

    Making customisation from the default profile is generally considered poor practice and quite often doesn't work out as planned. (If you're interested in some more information on this, [http://mockbox.net/windows-7/227-customise-windows-7-default-profile.html see here] see here)
    This article should help you with developing and deploying your customised Firefox 4 installation (without touching the Windows 7 default user profile):
    http://mockbox.net/configmgr-sccm/174-install-and-configure-firefox-silently.html

  • How can I write numbers with 7 digit in a ListView?

     

    Look at the attached vi to see how to use some basic tools to concatenate data and create your own data file format.
    CC
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    Save example.vi ‏30 KB

  • How can i write Recursive Program in PL/SQL

    Hi, i am new to Pl/sql Programming can any one suggest me with an example.
    I need to implenet this logic in one of my Procedure functionality

    I have to find whether my Userkey belongs to some groups and in that Gr
    oups there can be many more subgroup which means my user is indirectly
    associated with all Groups and Sub Groups so i need to check with the levels
    till the time there is no SubGroups associated with my the Main Group G1 are
    there.Seems you just need the hierarchy query:
    SQL> SELECT groups.grp, level
      2  from
      3  (
      4  select 'Group' grp, null parent from dual
      5  union all
      6  select 'Subgroup 1', 'Group' from dual
      7  union all
      8  select 'Subgroup 2', 'Group' from dual
      9  union all
    10  select 'SubSub 1', 'Subgroup 2' from dual
    11  union all
    12  select 'SubSub 2', 'Subgroup 1' from dual
    13  ) groups
    14  start with grp = (select grp from
    15  (
    16   select 'Key1' key, 'Subgroup 1' grp from dual
    17   union all
    18   select 'Key2' key, 'Subgroup 2' grp from dual
    19  ) userkeys
    20  where key = 'Key1'
    21  )
    22  connect by prior groups.grp = groups.parent
    23  /
    GRP             LEVEL
    Subgroup 1          1
    SubSub 2            2Rgds.

  • I need to change a photo into a video file in order to post on youtube. How can I do this with my mac?

    I need to change a photo into a video file in order to post in youtube. How can I do this with my mac mini?

    When I go to import, the choices are :
    movies
    camera archive
    imovie for IOS
    imovie for HD
    It refuses to import a photo with any of these choices, which is located on the desktop or in a folder. It's a regular .jpg
    There are instructions to drag it. I put it there, and it bounces right back. The photo will not stay.
    I just need this one picture to go on so I can post a meditation on youtube.  It doesn't come from a camera.

  • I have iPod shuffle 2nd gen. 1GB, how can I autofill it with more than 70 songs?

    I have iPod shuffle 2nd gen. 1GB, how can I autofill it with more than 70 songs, when I used to be able to get more than l20+ songs?

    Is your shuffle full after the Autofill?  Does the playlist you selected as the source have more than 70 songs?
    My 2nd gen 1GB shuffle currently has 140 songs on it, almost 100% full using Autofill.  The number of songs depends on two factors.  One is the average length of the songs.  Longer songs take more space.  A 20-minute symphony takes more space than a 4-minute pop song.  The other key factor is the bit rate used for compression.
    All of my songs are compressed using the AAC encoder at 256 kbps, which is Apple's current standard and the setting used for downloads from the iTunes Store.  The same songs compressed at 128 kbps AAC takes up half the space.  320 kbps MP3 would use more space per song.  If a lossless format, such as Apple Lossless or AIFF is used to encode, the sound quality is the best possibe, but the file size per song is MUCH higher.
    If you think there is problem on the shuffle, you can try doing a Restore in iTunes.  The Restore button is on the shuffle's Settings tab.  This will erase the shuffle, re-install its software, and set it to default settings. If there is data corruption on the shuffle's storage that is causing this problem, a Restore should fix it.

  • I write digital port by 'DAQmx Configure Logging.vi​' and receive TDMS file with 8 boolean channels. How can I write to 1 integer channel?

    Hello!
    I want to write 1 digital port from PXI-6536 with streaming to TDMS file.
    I'm writing by 'DAQmx Configure Logging.vi' and become TDMS file with 8 boolean channels.
    How can I write to 1integer channel?
    Attachments:
    1.JPG ‏27 KB

    Hey Atrina,
    The actual data stored on disk is just the raw data (that is, a byte per sample in your case).  It's really just a matter of how that data is being represented in LabVIEW whenever you read back the TDMS file.
    I'm not sure if there is a better way to do this, but here is a way to accomplish what you're wanting:
    Read back the TDMS file as a digital waveform.  Then there's a conversion function in LabVIEW called DWDT Digital to Binary.  This function will convert that set of digital channels into the "port format" that you're wanting.  I've attached an example of what I mean.
    Note: When looking at this VI, there are a few things that the downgrade process did to the VI that I would not recommend for these TDMS files.  It added a 1.0 constant on the TDMS Open function, and it set "disable buffering" on the TDMS Open function to false; you can get rid of both of those constants.
    Message Edited by AndrewMc on 01-27-2010 11:21 AM
    Thanks,
    Andy McRorie
    NI R&D
    Attachments:
    digitalconvert.vi ‏13 KB

  • How can I write to an SD card with my iPad 3?

    How can I write to an SD card/thumb drive with my iPad 3?

    Sorry to post this question before realizing others already did. HOWEVER! Why would Apple make such a cool device like the iPad without the abiity to write to an SD card?

  • How can I write the action attribute of a form dynamically using JSP

    I would like to do something like this:
    If the 'Accept-Language' of the http request is 'en', write out this in JSP:
    <form name='myform action="http://127.0.0.1/myservlet/en/>
    else if
    the 'accept-language' is 'es', write out this instead:
    <form name='myform action="http://127.0.0.1/myservlet/es/>
    else if no match
    <form name='myform action="http://127.0.0.1/myservlet/default/>
    How can I do that in JSP? I think this is simple enough so that I don' t need to use any of the Java Web framework/Java Beans.
    Thank you for any help.

    you can use a simple javascript for this:
    function setAction(lang){
       if(lang=="en"){
         document.forms[0].action="putYourservletUrlhere";
       }else if(lang=="es"){
         document.forms[0].action="putYourservletUrlhere";
       }else{
         document.forms[0].action="putYourservletUrlhere";
    }

  • How can I write the chinese characters in a web with my magic mouse?

    How can I write the chinese characters in the search box with my magic mouse?

    You can do it with a trackpad but I am not sure about the mouse.  Take a look at his link, http://support.apple.com/kb/HT4288

  • How can I write new objects to the existing file with already written objec

    Hi,
    I've got a problem in my app.
    Namely, my app stores data as objects written to the files. Everything is OK, when I write some data (objects of a class defined by me) to the file (by using writeObject method from ObjectOutputStream) and then I'm reading it sequencially by the corresponding readObject method (from ObjectInputStream).
    Problems start when I add new objects to the already existing file (to the end of this file). Then, when I'm trying to read newly written data, I get an exception:
    java.io.StreamCorruptedException
    at java.io.ObjectInputStream.readObject0(Unknown Source)
    at java.io.ObjectInputStream.readObject(Unknown Source)
    Is there any method to avoid corrupting the stream? Maybe it is a silly problem, but I really can't cope with it! How can I write new objects to the existing file with already written objects?
    If anyone of you know something about this issue, please help!
    Jai

    Here is a piece of sample codes. You can save the bytes read from the object by invoking save(byte[] b), and load the last inserted object by invoking load.
    * Created on 2004-12-23
    package com.cpic.msgbus.monitor.util.cachequeue;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.RandomAccessFile;
    * @author elgs This is a very high performance implemention of Cache.
    public class StackCache implements Cache
        protected long             seed    = 0;
        protected RandomAccessFile raf;
        protected int              count;
        protected String           cacheDeviceName;
        protected Adapter          adapter;
        protected long             pointer = 0;
        protected File             f;
        public StackCache(String name) throws IOException
            cacheDeviceName = name;
            f = new File(Const.cacheHome + name);
            raf = new RandomAccessFile(f, "rw");
            if (raf.length() == 0)
                raf.writeLong(0L);
         * Whne the cache file is getting large in size and may there be fragments,
         * we should do a shrink.
        public synchronized void shrink() throws IOException
            int BUF = 8192;
            long pointer = getPointer();
            long size = pointer + 4;
            File temp = new File(Const.cacheHome + getCacheDeviceName() + ".shrink");
            FileInputStream in = new FileInputStream(f);
            FileOutputStream out = new FileOutputStream(temp);
            byte[] buf = new byte[BUF];
            long runs = size / BUF;
            int mode = (int) size % BUF;
            for (long l = 0; l < runs; ++l)
                in.read(buf);
                out.write(buf);
            in.read(buf, 0, mode);
            out.write(buf, 0, mode);
            out.flush();
            out.close();
            in.close();
            raf.close();
            f.delete();
            temp.renameTo(f);
            raf = new RandomAccessFile(f, "rw");
        private synchronized long getPointer() throws IOException
            long l = raf.getFilePointer();
            raf.seek(0);
            long pointer = raf.readLong();
            raf.seek(l);
            return pointer < 8 ? 4 : pointer;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#load()
        public synchronized byte[] load() throws IOException
            pointer = getPointer();
            if (pointer < 8)
                return null;
            raf.seek(pointer);
            int length = raf.readInt();
            pointer = pointer - length - 4;
            raf.seek(0);
            raf.writeLong(pointer);
            byte[] b = new byte[length];
            raf.seek(pointer + 4);
            raf.read(b);
            --count;
            return b;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#save(byte[])
        public synchronized void save(byte[] b) throws IOException
            pointer = getPointer();
            int length = b.length;
            pointer += 4;
            raf.seek(pointer);
            raf.write(b);
            raf.writeInt(length);
            pointer = raf.getFilePointer() - 4;
            raf.seek(0);
            raf.writeLong(pointer);
            ++count;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCachedObjectsCount()
        public synchronized int getCachedObjectsCount()
            return count;
         * (non-Javadoc)
         * @see com.cpic.msgbus.monitor.util.cachequeue.Cache#getCacheDeviceName()
        public String getCacheDeviceName()
            return cacheDeviceName;
    }

Maybe you are looking for

  • Export movie with alpha to png sequence

    I'm trying to export tweened animation to .png image sequence with alpha transparency. The individual png files appear to be clean -- but when I open the file sequence in QuickTime, it looses the 8-bit alpha. Anyone know how to get around this? Thank

  • Invalid serial number when upgrading to Aperture 2

    I purchased aperture 2 upgrade version and I tried all afternoon to install it. There was no problem inputing the serial number that comes with the DVD. I didn't have my serial number for 1.5 so I opened Aperture 1.5 and look up the original serial n

  • Scanner giving me a a hard time.

    I have spent hours on this and I am at my wits end. (I admit it is not a long journey) I'll be as brief and descriptive as I can. I have a Canon Pixma 960 and I used to happily click on the Cannon ikon on my dock, up would pop what I now think of as

  • 10.7 Install Issues

    Having issues with downloading and installing 10.7 for the first time.  Also first-time user of the Mac App Store. I purchased 10.7, downloaded the installer and tried running it from the /Applications folder.  When it launched and the computer resta

  • I can't get my E-mails

    I can not get my E-mails.  It tells me it is something wrong in the area.