Concurrent Access to JDBC from JSP

I'm sure that I am not the first to ask this !!
I have a JSP page that uses a bean to access a database table.
This page gets a set of records, and displays a list, with the Primary key set to a hyperlink.
This link tkaes the user to a detail page, that gets the specific record and displays all the fields.
Now, if while the index page is running it's query, another page also runs the query, the two lists get mixed up, or if a user calls up the detail page, while another is running the list, the detail page doesn't grab the correct record.
I have set <%@ page isThreadSafe="false" %> on every JSP page, and also set every public method in the bean to synchronized, but still the problem.
The bean has PAGE scope.
Any ideas ?? It's driving me nuts !!

I am facing the same problem...... When same JSP Page Query is accessed by more than one client at the same time, results get mixed up. Is there any to prevent this....Please HELP!!!!!!!!!!!!!!!!!

Similar Messages

  • Urgent-how to access custom tag from jsp tag

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

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

  • Problem with accessing init parameters from JSP file

    Hi,
    I have my init parameters and Jsp configured in web.xml
    <servlet>
              <servlet-name>TestJsp</servlet-name>
              <jsp-file>/Test.jsp</jsp-file>
              <init-param>
                   <param-name>username</param-name>
                   <param-value>Balboa</param-value>
              </init-param>
    </servlet> How do I access 'username' field from JSP file.
    Kindly help.
    Thanks.

    you can do this in the jsp
    <%=config.getInitParameter("username")%>or do it in the jspInit method in the jsp:
    <%!  String userName = null; 
      public void jspInit() {   
        ServletConfig config = getServletConfig();   
        userName   = config.getInitParameter("userName ");  
    %>
    Hello <%=userName%>

  • How to access COM+ Objects From JSP

    Friends,
    We have a requirement to access COM+ objects from JSP. Please guide me on this.
    Thanks in advance.
    Tarani

    Sanyam wrote:
    if there is any .dll extension file, how can we read that file in labview?
    You can use Call Library Function node to call that dll file and use it in LabVIEW. Read the help and you will get more details.

  • Setup mySQL and access the same from jsp

    Hi,
    I have installed the MySQL in local desktop in d: drive. As per the documentation, have created my.cnf file to point sql directory in d drive.
    Now I dont know how to proceed further. I need to see if MySQL installation is fine, create table and access the data in jsp page. Please advice.
    Thanks in advance.

    For MySQL help try a MySQL forum.
    For connecting to the database, use JDBC. You can get the MySQL JDBC driver from www.mysql.com.
    From there just follow standard java database connection setup.
    http://java.sun.com/docs/books/tutorial/jdbc/index.html

  • Error while accessing EJB method from JSP

    Hi,
    I am trying to access a bean from a JSP and have the foll. code piece:
    String url = "t3://localhost:7001";
    public Context getInitialContext() throws Exception {
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY,
    "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, url);
    return new InitialContext(p);
    String getStackTraceAsString(Exception e)
    // Dump the stack trace to a buffered stream, then send it's contents
    // to the JSPWriter.
    ByteArrayOutputStream ostr = new ByteArrayOutputStream();
    e.printStackTrace(new PrintWriter(ostr));
    return(ostr.toString());
    %>
    <%
    String op="";
    try {
    // Contact the AccountBean container (the "AccountHome") through JNDI.
    Context ctx = getInitialContext();
    out.println("initial context got !!");
    DemoHome home = (DemoHome) ctx.lookup("demo.DemoHome");
    out.println("home got !!");
    %>
    <p>
    <%
    Demo ac = null;
    try {
    ac = (Demo) home.create();
    out.println("create called!!");
    if (ac==null)
    out.println("ac is null!");
    catch (Exception ee) {
    out.print("exception 1");
    %>
    <p>
    <%
    try {
    out.println("going to call method!");
    if (ac!= null)
    op = ac.demoSelect(); /* FAILURE POINT */
    else
    out.println("ac is null->error!!");
    out.println(ac.demoSelect());
    out.println("string got!!");
    out.println(op);
    catch (Exception e) {
    getStackTraceAsString(e);
    e.printStackTrace();
    out.println("error 2");
    catch(Exception e)
    out.println("error 3!");
    It gives an error on trying to access the method "demoSelect".
    e.printStackTrace gives the output:
    java.lang.RuntimeException: javax.ejb.EJBContext.getEnvironment is deprecated in EJB 1.1. EJB 1.1 compli
    ant containers are not required to implement this method. Use java:comp/env instead.
    <<no stack trace available>>
    JSP output is as foll.-->
    getting initial context initial context got !! home got !!
    create called!!
    going to call method! error 2
    What is wrong???
    pls help!

    Greetings,
    Hi,
    I am trying to access a bean from a JSP and have the
    foll. code piece:
    <%
    String op="";
    try {
    // Contact the AccountBean container (the "AccountHome") through JNDI.
    Context ctx = getInitialContext();
    out.println("initial context got !!");
    DemoHome home = (DemoHome) ctx.lookup("demo.DemoHome");
    out.println("home got !!");Though it doesn't seem to be the problem in this case, good EJB coding practices dictate that your code should be narrowing the home reference before calling any of it's methods (i.e. create(...) )... WebLogic may allow handling of its protocol objects in their native state, but other vendors do not... your application is not portable without narrowing.
    It gives an error on trying to access the method "demoSelect".
    e.printStackTrace gives the output:
    java.lang.RuntimeException: javax.ejb.EJBContext.getEnvironment is deprecated inThe error is not in your JSP, but in the bean... it seems your bean is attempting to acquire its "environment properties" in the pre-1.1 style, when...
    EJB 1.1. EJB 1.1 compliant containers are not required to implement this
    method. Use java:comp/env instead. ...instead, it should be looking them up in its JNDI namespace.
    What is wrong???
    pls help! Regards,
    Tony "Vee Schade" Cook

  • Accessing file shares from JSP

    Hi,
    I need to be able to access file shares from a JSP page. Here's the JSP code:
    <%@ page language="java" %>
    <%@ page import="java.io.*" %>
    <%@ page errorPage="errorPage.jsp" %>
    <%
    String fileSystemPath = "\\\\130.26.1.199\\MeetingManager30\\test.txt";
    File f = new File(fileSystemPath);
    f.createNewFile();
    %>The above code resides in a server with IP 130.9.68.6 and is deployed onto the Tomcat on the server.
    When I tried to run the above code, I got this error
    java.io.IOException: Access is denied at java.io.WinNTFileSystem.createFileExclusively(Native Method) at java.io.File.createNewFile(File.java:827) at org.apache.jsp.test_jsp._jspService
    (test_jsp.java:55) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServletWrapper.service
    (JspServletWrapper.java:210) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) 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:256) 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.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:2422) at
    org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invok
    eNext(StandardPipeline.java:643) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171) at
    org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
    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:199) at
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processCon
    nection(Http11Protocol.java:711) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
    (ThreadPool.java:687) at java.lang.Thread.run(Thread.java:536) Seems like I'm having a system level security setting problem here.
    I know it's a security issue, because I've encountered the equivalent problem in ASP/IIS, and I had to give a domain user rights to both the IIS Virtual Directory, and the file share to be able to access.
    Any ideas how to set up Tomcat to be able to access the file share successfully?
    Thanks in advance!

    Hello Veer,
    From what you have posted it looks like while logging your error another problem occurred. Did you get any output from your System.out calls? If not can you try adding a few in order to home in the problem area.
    Hussein Badakhchani
    www.orbism.com

  • Problem with access to SipFactory from jsp-pages in JBoss environment

    Hello!
    I have an installation of the OCMS 10.1.3.3. deployed into a JBoss (jboss-4.0.5.GA) environment. Unfortunately I have a problem with accessing the SipFactory from a jps-page. Encouraged by the "messagesender" example I tried to get an instance of SipFactory from my jsp-page simply by calling:
    SipFactory sipFactory = (SipFactory) application.getAttribute(SipServlet.SIP_FACTORY);
    But unfortunately there seems to be no attribute "SipServlet.SIP_FACTORY" and I only get a null pointer. I have also tried running that code in the orignal messagesender example but it didn't work either. So I wonder if this should definetely work in a JBoss environment or if this might be a known problem. Is there anything that I could check/do regarding this problem? I suppose there must be an oracle module which should take care of making the SipFactory availabe after it is deployed. Perhaps something went wrong during the deployment?!
    Best regards,
    Tim

    Hi
    On JBoss, OCMS does not support converge applications.
    I.e the SipFactory can be retrieved from the servlet context when running on OC4J.
    Instead the SipFactory can be found in JNDI as described in the Developer's Guide:
    "External Access to SIP Servlets
    To enable convergent applications between SIP and HTTP, the OCMS Container allows you to get access to the javax.servlet.sip.SipFactory by looking it up through JNDI. The SIP Factory will be registered under the same name as the display name of your SIP servlet as illustrated in Example 2–12. The <display-name> in the sip.xml in this case must be "My sip app".
    Example 2–12 Accessing the Data for a SIP Session through JNDI
    InitialContext ic = new InitialContext();
    SipFactory sipFactory = (SipFactory)ic.lookup("sip/My sip app");"
    Cheers
    Lucas Persson

  • Accessing JSTL values from JSP

    I've run into a problem I'm not sure has a solution. Could be bad design on my part, or just a poor imagination. If this has been answered previously, please point me to the post.
    I am using some JSTL to do a SQL query and displaying the records in a select box:
    <sql:query var="aResults" sql="select * from TYPE_STATE_LIST where tslAllowable=1" />                           
    <c:forEach var="oRecord" items="${aResults.rows}">                               
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option>                                   
    </c:forEach>I want to be able to reset their selection to the value they entered when the form is refreshed, though. I'm trying to figure out how to grab the oRecord value from the JSTL and use it in a JSP IF statement:
    <% if( oRecord.tslID==request.getParameter("state") ) { %>
      <option selected value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } else { %>
      <option value="<c:out value="${oRecord.tslID}" />"><c:out value="${oRecord.tslFullName}" /></option> 
    <% } %>I thought about using the JSTL <c:choose> tag instead, but then how would I access the previous value with request.getParameter()?
    Any suggestions?

    ${param.state}It's better if you place the sql query into a class rather than display it in the jsp, it's more flexible and programmable.

  • Accessing custom classes from JSP

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

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

  • How to access MDB database from JSP Web Application?

    hi
    i am using tomact and developing appplication in which i have to insert data into MDB database and read/Update/Delete Data in MDB DataBase.
    could any help in this issue?
    Thanks
    Regards
    Oersla Afroze Ahmed

    Hi,
    For accessing MDB database, you must have a jdbc:odbc driver, u can get it from sun site.
    just put it into the lib folder of web server.
    or
    just follow the following link:
    http://www.developer.com/db/article.php/3571661
    keshri

  • JDBC from jsp (performance)

    Hello everybody.
    I am developing a web application with jsp and beans, i have a connector bean that opens a connection with a database, then this connection is setted in the session, so the other classes can use it to create preparedStatements.
    First Question:
    Is this the best way to do it? i would appreciate any other suggestion that improves performance and reliability.
    Second Question:
    What is the best way to manage concurrent connections to the database, as i have modeled it, there will be one connection per user, but what if there is 100 users at the same time, if i need this application to be fast and reliable, what would you suggest... thank you very much. Bye
    Otto

    There is no golden rul to build the system. Every situation may need different best answer. However, field experts established some common wisdom which has been proved to be good in many situations.
    1. Model 2 : Like other dynamic content technology, JSP is suffering the problem of sharing sources between tech and non-tech people. Avoiding as much as java codes in jsp will remove much headaches. Model in JSP spec is recommended in that sense. (Still you can't avoid accusing other side for messing up the code, if your desing is not complete up front)
    2. Connection Pool. is the most common way to reduce the overhead of creating the connection to the database. Keep the connections in some in-memory store and reuse them.
    3. Focus on building the whole system instead of building view components. Solidly designed back-end server properly equipped with data caching will improve your system as a whole.
    Cheers,

  • Problem accessing session variable from jsp

    Hi!
    I get an error retrieving a session variable from inside a JSP declaration scriptlet....
    Something like this code in a JSP page:
    <%!
    public void funtion1() {
    String parameter1 = session.getAttribute("parameter1");
    %>I have seen that I have available getContextServer() method and from there I could call getAttribute("parameter1") . But the thing is that the attribute I want to retrieve was stored in session by another Jsp page.
    Any solutions are welcome
    Cheers
    Victor

    Appropriately the above is one the reasons also You cannot use JSP implicit objects from the declaration tag. However we can think of a small workaround by passing the reference like the one discussed below
    <%!public void funtion1(HttpSession session) {
    String parameter1 = session.getAttribute("parameter1").toString();
    }%>
    <% funtion1(session);%>Hope that helps :)
    REGARDS,
    RaHuL

  • Accessing Constant classes from jsps

    org.apache.struts.taglib.html.Constants is a java constant class with no getter/setter methods
    is this the only way (not using other form beans) to get the value of a constant within that class
    can we use pageContext or any other expression language to do things like this?
    <c:set var="tokenKey">
    <jsp:expression>
    org.apache.struts.taglib.html.Constants.TOKEN_KEY
    </jsp:expression>
    </c:set>
    thank you

    EL doesn't have any way to access constants.
    What you have there is pretty much the only method without using other beans.
    There are certain workarounds that have been proposed. Javaranch had an article on it a while ago:
    http://www.javaranch.com/journal/200601/Journal200601.jsp#a3
    A previous thread on this topic, with a proposed solution: http://forum.java.sun.com/thread.jspa?threadID=508847

  • How can I access Excel spreedSheet from JSP under Unix

    I have Jrun webserver running on Unix. I want to write a JSP application that will open Excel spreedsheet. Please let me know if anyone has done this kind of thing. Thanks.

    Well there can be various solutions if u really wanna try. The best one is as below.
    Ms-Excel has the facility to save an spreadsheet as an HTML page. That solves all ur problems.

Maybe you are looking for