How do I expand my simple JSP page to implement Connection Pooling?

Hi everyone,
I have a small SQL database which contains information about Students and a StudenBean which contains their attributes and appropriate get/set methods (which I haven't needed to use yet).
I want to write a simple JSP page which displays all the students details in one big table. I can do this using the basic prototyping method of adding the dataSource and driver details to the deployment descriptor (web.xml - I'm using the latest version of Tomcat by the way) and then accessing the database using JSP standard SQL actions.
Here's a snipet of what I've done (just an example, the final code works):
<sql:query var="temp"
sql="SELECT * FROM Employee ORDER BY UserName"
/>
<c:forEach items="${temp.rows}" var="row">
<td><c:out value ="${row.UserName}"/></td>
<td><c:out value ="${row.FirstName}"/></td>
<td><c:out value ="${row.LastName}"/></td>
Now I want to upgrade! I want to access the dataSource using Connection Pooling and it's causing me a lot of trouble. I already have the required working classes/data such as ConnectionPool.java, ResourceManagerListener.java, the MySQL driver etc.
However, I don't know what the best way to setup the connection for my purposes would be and where I should do it.
Do I need to write a servlet or tag handler/custom action to establish the connection and access my bean through it? I would like to keep a similar sort of business logic as I already have developed i.e. be able to use actions in my JSP page to cycle through the database and print out each detail from the row.
Rather confused and muddled. Thanks for any input!

Good idea.
Set up a JNDI data source for your app, according to these docs:
http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-datasource-examples-howto.html
You'll have to put the right information into your web.xml and a context.xml. Once you've done that, your JSTL JSPs will simply use the connection resource automagically.
MOD

Similar Messages

  • Can't us Oracle API on the simple JSP pages added to the portlet........

    Hi,
    I added a jsp page in the portlet which is not a standard page like the default show mode pages. I have added some code which actually access a resource inside the porltet.
    " img src="<%= UrlUtils.constructResourceURL (pReq, HttpPortletRendererUtil .absoluteLink(request, "icon.png")) %> "
    For that you have to add the following two imports in the code
    mport="oracle.portal.provider.v2.render.http.HttpPortletRendererUtil"
    import="oracle.portal.provider.v2.url.UrlUtils"
    This library is available with the JDeveloper and I dont get any error while compiling and even deploying the portlet war file on the applcation server. Strangely the same piece of code shows the image perfectly for the default show page of the portlet but it generates 500 Internal server error for the other simple jsp page I added, which suggests that the server is unable to find the function:
    500 Internal Server Error
    java.lang.NullPointerException
         at oracle.portal.provider.v2.url.UrlUtils.constructResourceURL(Unknown Source)
         at _htdocs._elogbooksubsystems._DAQ._jspService(_DAQ.java:54)
         [SRC:/htdocs/elogbooksubsystems/DAQ.jsp:15]
         at com.orionserver[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].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[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:824)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:285)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.HttpRequestHandler.run(HttpRequestHandler.java:126)
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
         at java.lang.Thread.run(Thread.java:534)
    Can anybody help? Is this possible to use oracle api in the pages which are though added to the portlet but not the standard show modes pages?
    Thanking you in anticipation
    Regards,
    Omer Alvi
    Message was edited by:
    user574208
    Message was edited by:
    user574208

    Thanks Nrintala. I tried to work with multipage portlet example provided in the jpdk. In fact I created another portlet with two pages and copied the code of the two pages of the multipage portlet. (Off course I took care of the names and stuff). Later I modified the provider.xml by defining "next_page" parameter. When I viewed my portlet, first page appeared fine but when I click on the link which should show the second page, I got an error which says.
    Error:      Error occurred while rendering portlet - see provider log file for details.
    Do you think I have missed something? I am depoying my war file on the stand alone OC4J and some how I have not been able to find the application.log file in my application inside the application_deployments of the J2EE_HOME. I have pasted the provider.xml file and I would be grateful if you can help.
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <?providerDefinition version="3.1"?>
    <provider class="oracle.portal.provider.v2.DefaultProviderDefinition">
    <session>false</session>
    <passAllUrlParams>true</passAllUrlParams>
    <portlet class="oracle.portal.provider.v2.DefaultPortletDefinition">
    <id>1</id>
    <name>mulitpage</name>
    <title>testing multi page</title>
    <description>My Portlet Description</description>
    <timeout>40</timeout>
    <showEditToPublic>false</showEditToPublic>
    <hasAbout>false</hasAbout>
    <showEdit>false</showEdit>
    <hasHelp>false</hasHelp>
    <showEditDefault>false</showEditDefault>
    <showDetails>false</showDetails>
    <renderer class="oracle.portal.provider.v2.render.RenderManager">
    <contentType>text/html</contentType>
    <showPage>/htdocs/mulitpage/first.jsp</showPage>
    <pageParameterName>next_page</pageParameterName>
    </renderer>
    </portlet>
    </provider>
    Best regards,
    Omer
    Message was edited by:
    user574208
    Message was edited by:
    user574208

  • How to print new line in jsp page

    hi
    how to print new line in jsp page
    thanks

    \n - new line character is in java specific not HTML
    specific.Well, if the correct line separator sequence (by far not always \n) would be used, it does add a new line to the HTML output. Too bad that you don't want to see HTML but formatted text. The BR tag is a formatting element for the displayed text, not a line break in HTML. ;)

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • How to enable the EL in jsp page

    hi can u tell 'how to enable the EL in jsp page'?

    *I am getting below exception in tomcat when i inclued +<%@ page isScriptingEnabled="true" isELEnabled="true"%>+*
    org.apache.jasper.JasperException: /index.jsp(1,1) Page directive has invalid attribute: isScriptingEnabled
         org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
         org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
         org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
         org.apache.jasper.compiler.JspUtil.checkAttributes(JspUtil.java:311)
         org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:106)
         org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:590)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2388)
         org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2394)
         org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
         org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2338)
         org.apache.jasper.compiler.Validator.validate(Validator.java:1700)
         org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:178)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:306)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

  • How to call BPEL process in JSP page

    Hi
    I am new to BPEL.please help me how to call BPEL process in JSP page.
    Thank You...

    Check this thread ....
    How can i call asyncronous BPEL process from Java Class????
    Tom..

  • How to Hightlight the Data in Jsp Page

    How to Hightlight the Data in Jsp Page,
    I am doing doing search page,based on values given search page those are sent to servlet,in servlet based on some conditions if particuler id i am getting then i am redirecting to Respective jsp page with highlight the data from database..
    Thanks in advance...

    "Highlighting data in JSP sounds strange".
    Without looking at your search specific algorithms I feel you are finally going to display a page (HTML content) to user which contains highlighted text. Highlighting is not directly related to server side language you use (JSP, ASP, PHP etc.). This is purely HTML and CSS. However, server side script (such as JSP) should generate HTML content for getting highlight effect.
    Following HTML shows highlighted text using background-color property on span element.
    <html>
      <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
      </head>
      <body>
          <p style="font-size:1.1em">This is a long paragraph which contains <span style="background-color: yellow;">highlighted text</span> and non highlighted text.</p>
      </body>
    </html>Thanks,
    Mrityunjoy
    Edited by: mrityunjoy on 14 Jun, 2010 3:30 AM

  • 10.1.3.4 - how to secure access on a jsp page ?

    I have a simple jsp page that takes in some user values and then kicks off a workflow. I want to restrict the access on the jsp page so that only users of a certain group can use it. right now it is completely open and anyone can just go the page and start of a transaction.

    found an article on this
    http://www.oracle.com/technology/products/jdev/howtos/1013/adfsecurity/adfsecurity_10132.html

  • Oepe-12.1.2.1-kepler how to use ADF Templates in JSP page

    Hi all,
        I use oepe 12.1.2.1 kepler 4.3 and creating JSP page but I can't see any ADF Rich Faces Page in JSP Templates Page of Preferences Dialog. How to use ADF Templates in JSP page?
    Thanks,
    Thomas

    Select the JSP Templates link. Is the ADF Rich Faces Page template listed? Refer Creating the Login Page/4.
    Introduction to the Oracle Enterprise Pack for Eclipse (OEPE) IDE

  • How to debug a bean in JSP page with JBX???

    How to debug a bean in JSP page with JBX???
    i have a bean within a JSP page. i wanna find out how do they varibles work and changes of them values.
    are there some ways or tools to get the situations of them in visual way? just like when i debug VB program,i can get the situations in immediately window.

    help me !!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  • How to pass parameter to intro.jsp page ?

    Hi all,
    Anybody please tell me how to pass parameter to intro.jsp page.
    Is there any param name defined in <forward > syntax ?
    I have made following configuration in struts-config.xml file.
    I want to pass parameter to intro.jsp page
    <global-forwards>
              <forward name="invalidsession" path="/intro.jsp" redirect="true" />
    </global-forwards>
    please reply soon.
    Thanking you.

    Hi all,
    I have a similar kind of question..
    Iam trying to pass a string variable from JSP to servlet thro URL..
    Im using tomcat5
    COde:
    String fname=request.getParamter("filename");
    <jsp:forward page="/servlet/coreservlets.filedownload?name=" +fname />
    It is generating a unterminated tag error..Please help..

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How to Make simple JSP page running on TOMCAT 5.5.14

    Hi, Friends
    I have tried many to put test.jsp page in my webapps folder in tomcat installation directory and try to run http://localhost:8080/test.jsp but it will showing errors instead of running it.
    And will u provide me the basic and simple structure of creating the WEB-INF, src, web.xml, build.xml etc. etc.
    I am using my OS as WinXP prof. with sp2.
    also please post answer on mail. [email protected]

    Create a dir under webapps say "mydir"
    under this dir place your .jsp file and create WEB-INF directory too
    and run
    http://localhost:8080/test.jsp

  • How do you invoke a simple jsp

    hi,
    i have a very simple jsp that displays the current time. it works on my tomcat server (installed on my computer). i purchased a domain from yahoo, say, www.beginer.com and uploaded the jsp file to the yahoo server. but when i referenced it with the url www.beginer.com/MyJSP.jsp, a download dialog popped up.
    so, how do you get the browser to display the dynamic contents of the jsp file?
    thanks.

    Did you ask Yahoo whether their server supports servlets and JSPs? Or did you just assume that? I would expect that it doesn't.

  • How to get multiple selections from jsp page in my servlet

    Hello Everyone,
    I've a list that allows users to make multiple selections.
    <select name=location multiple="multiple">
        <option>
             All
        </option>
        <option>
             Hyd
        </option>
        <option>
             Dub
        </option>
        <option>
             Mtv
        </option>
      </select>I want to get the selections made by user in jsp page from my servlet, selections can be multiple too.
    ArrayList locList = new ArrayList();
    locList = request.getParameter("location");when I do so, I get compilation error as the request returns string type. How do I then get multiple selections made by the user.
    Please let me know.

    For those kind of basic questions it would help a lot if you just gently consult the javadocs and tutorials.
    HttpServletRequest API: [http://java.sun.com/javaee/5/docs/api/javax/servlet/http/HttpServletRequest.html]
    Java EE tutorial part II: [http://java.sun.com/javaee/5/docs/tutorial/doc/]
    Coreservlet tutorials: [http://courses.coreservlets.com/Course-Materials/]

Maybe you are looking for

  • PO Document type change & verson problem in one po

    Hai Friends, U used change po document type after creation of po. now For one po i couldn't able to change. what could be the reason ? for that po verson also not coming please tell me

  • Sync key not working

    I am trying to pair my firefox and got the sync key from firefox as per the instructions in the set up. It keeps telling me the sync key i am entering is not correct. Is there a way to find out what my sync key is and if the one i have been giveen is

  • Data Integration from E-Biz Suite to Hyperion Planning

    Hi Experts, I am using EPM 11.1.1.1.0. I have a requirement of integrating data from Oracle Gl to Hyperion. I am going to use ODI for achieving the same but i observed a fact in GL around which i need some help. Oracle GL maintains a relation between

  • Making new photo albums and slide shows

    Is there a way to make new photo albums or slides shows on the iPad? I wish to organize photos and create slide shows while I am on the road, away from my sync computer.

  • Error in index creation: null

    Hi, I have a problem when I try to create an index. The message I get is: Could not create the index: null But apparently the index is created. I try to add data sources but then i get portal runtime error. Looking in TREX monitor the Queue is create