NoSuchMethodError: HttpServletRequest.getSession()

I've installed Oracle 8i AS on NT4. It comes with Apache JServ v1.0 - apparently complient with Servlet API v2.0 - and JVM v1.1.
I've checked Servlet API v2.0 on Sun's site and HttpServletRequest.getSession() is definitely there! So why do I get the following error in jserv.log?
[26/01/2001 14:33:36:453 GMT] java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest: method getSession()Ljavax/servlet/http/HttpSession; not found
at org.apache.jserv.JServConnection.processRequest(JServConnection.java)
at org.apache.jserv.JServConnection.run(JServConnection.java)
at java.lang.Thread.run(Thread.java:479)
Thanks in advance for your help.
JMR
null

The issue was with some HTTP port change and not with the above code.

Similar Messages

  • ADF 10g:HttpServletRequest.getSession vs ExternalContext.getSession

    Hi all,
    I'm reviewing some code in our application and I would like to confirm my understanding of how to properly use session attributes on the view layer.
    In my servlet doFilter method I get my session using:
    HttpSession session = servletRequest.getSession(true);
    I also came across this blog post:
    http://andrejusb.blogspot.com/2012/01/how-to-access-session-scope-in-adf-bc.html
    which calls getSession from FacesContext.getCurrentInstance().getExternalContext.getSession
    http://docs.oracle.com/cd/E17802_01/j2ee/j2ee/javaserverfaces/1.2/docs/api/javax/faces/context/ExternalContext.html#getSession(boolean)
    Am I correct in my understanding that according to the javadoc, the getExternalContext.getSession returns the same HttpSession object as in HttpServletRequest.getSession?
    Many thanks
    Wes

    Hi,
    yes, this is correct
    Frank

  • Is HttpServletRequest.getSession() atomic?

    Can I assume that this method execution is atomic?
    I.e., suppose there are two HTTP requests from the same user
    calling this method without synchronization.
    Both requests are from the same user, but have no HttpSession associated
    with them, so a new session must be created.
    Can I assume, that one of the requests will create a new session and the other
    will just obtain the reference to the HttpSession object?
    Can it happen that 2 new sessions will be created?

    By the same user, I assume you mean two browser
    windows opened
    on the same machine.Yes
    I would expect the following:
    Browser #1 connects to your application URL resulting
    in the creation
    of a new HttpSession.
    Browser #2 connecting to the same URL will have its
    own HttpSession establishedYes, but here you talk about two different users, i.e., two different browsers
    (no parent-child relationship)
    >
    The only other behavior I'm familiar with is: IF....
    Browser #1 connects, creates HTTPSession then the
    window spawns a new window (i.e. <cntrl> N)
    then Browser #2 will be created with the same session
    id, in its browser header and will
    be communicating to the same session created by
    Browser #1Right! (And why is that?)
    Anyway, we cannot be sure how the two HTTP requests will arrive at the server.
    They can arrive simultaneously and in that case the method getSession() will be called
    by 2 threads without synchronization.
    The question is - whether SUN has foreseen this scenario.
    Another possible scenario - a user that clicks his mouse too fast and creates
    many HTTP requests in the same session.
    Thanks for replying.

  • GetSession()

    hi to @ll,
    while getSession is used like:
    method (HttpServletRequest request,
    HttpServletResponse response, ...)
    HttpSession session = request.getSession();
    iAS server responses:
    java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest: method getSession()Ljavax/servlet/http/HttpSession; not found
    any idea?
    thanks anyway,
    marcos.

    shaolinf wrote:
    Hi Guys
    How does the true or false in the getSession() attribute affect its state?[HttpServletRequest.getSession(boolean)|http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpServletRequest.html#getSession(boolean)]
    Affects the state of what?
    A method does not have a state.
    If there already is a session - there is no state change.
    If there is no session yet - a session is created if the argument is true.

  • Session - getSession(true)

    I have two servlet . In first sevrlet i m creating a session and i am using setAttribute(uname,"abc"). Then i m redirecting to second servlet . In second servlet i have getSession(true). That means i m creating a new session. Then i am giving :
    if (session != null)
    String name = (String) session.getAttribute("uname");
    // some more code here
    else
    out.println("You are not authorised to access this information");
    Since it is new session, 'else' code should be executed , but its going in 'if' condition..

    There are two methods from which you can get HttpSession object
    HttpServletRequest.getSession()
    Returns the current session associated with this request, or if the request does not have a session, creates one.
    HttpServletRequest.getSession(boolean create)
    Returns the current HttpSession associated with this request or, if if there is no current session and create is true, returns a new session.
    If create is false and the request has no valid HttpSession, this method returns null.
    To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
    regards,

  • IAS JServ (servlet) configuration problem

    I hava a very simple servlet that calls request.getSession() method. It runs OK from JDeveloper environment, but on iAS I get an Internal Server Error.
    error_log shows:
    java.lang.NoSuchMethodError: javax.servlet.http.HttpSession javax.servlet.http.HttpServletRequest.getSession()
    void org.apache.jserv.JServConnection.run()
    void java.lang.Thread.run()
    My jserv.properties file has
    # Oracle Servlet
    wrapper.classpath=c:\oracle\ias\jsp\lib\servlet22.jar
    What am I missing?
    Thanks a lot...
    Glenn
    null

    Hi TechnoSam,
    The problem here is, you are not following the correct directory structure.
    consider your webapplication is placed in a directory called $TOMCAT_HOME$/webapps/TechnoSamAPP
    by default the default context will be $TOMCAT_HOME$/webapps/ROOT
    If you want to have your own context, create a directory in webapps like
    if you have created a directory Example: TechnoSamAPP
    it will become a Web Application Context and which expects a <Context> entry in server.xml file.
    You can copy all your files in to this directory by follwoing the directory structure mentioned in the servlet spec SRV.9.5.
    You need to place all static resources(*.html, *.jpg, *.gif, *.js, *.css) in this context root directory
    i.e.,
    /webapps/TechnoSamAPP
    � The /webapps/TechnoSamAPP/WEB-INF/web.xml deployment descriptor.
    � The /webapps/TechnoSamAPP/WEB-INF/classes/ directory for servlet and utility classes. The classes in this directory must be available to the application class loader.
    � The /webapps/TechnoSamAPP/WEB-INF/lib/*.jar area for Java ARchive files. These files contain
    servlets, beans, and other utility classes useful to the web application. The web application class loader must be able to load classes from any of these archive files.
    The web application classloader must load classes from the WEB-INF/ classes
    directory first, and then from library JARs in the WEB-INF/lib directory.
    Hence place all your static files (which are accessible for public) into the Context's root directory rather than Tomcat/bin.
    Place all servlets in to /WEB_INF/classes which will be accessed by Servlet Container.
    Thanks,
    Sanath Kumar

  • Strange behavior when using servlet filter with simple index.htm

    I am new to J2EE development so please tolerate my ignorance. I have a web application that starts with a simple index.htm file. I am using a servlet filter throughout the website to check for session timeout, redirecting the user to a session expiration page if the session has timed out. When I do something as simple as loading the index.htm page in the browser, the .css file and one image file that are associated, or referenced in the file are somehow corrupted and not being rendered. How do I get the filter to ignore css and image files??? Thank you!!
    The servlet filter:
    import java.io.IOException;
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class SessionTimeoutFilter implements Filter {
         String[] excludedPages = {"SessionExpired.jsp","index.htm","index.jsp"};
         String timeoutPage = "SessionExpired.jsp";
         public void destroy() {
         public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
              if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
                   HttpServletRequest httpServletRequest = (HttpServletRequest) request;
                   HttpServletResponse httpServletResponse = (HttpServletResponse) response;
                   //httpServletResponse.setHeader("Cache-Control","no-cache");
                   //httpServletResponse.setHeader("Pragma","no-cache");
                   //httpServletResponse.setDateHeader ("Expires", 0);
                   String requestPath = httpServletRequest.getRequestURI();
                   boolean sessionInvalid = httpServletRequest.getSession().getAttribute("loginFlag") != "loggedIn";               
                   System.out.println(sessionInvalid);
                   boolean requestExcluded = false;
                   System.out.println(requestExcluded);
                   for (int i=0;i<excludedPages.length;i++){
                        if(requestPath.contains(excludedPages)){
                             requestExcluded = true;
                   if (sessionInvalid && !requestExcluded){
                        System.out.println("redirecting");
                        httpServletResponse.sendRedirect(timeoutPage);
              // pass the request along the filter chain
              chain.doFilter(request, response);
         public void init(FilterConfig arg0) throws ServletException {
              //System.out.println(arg0.getInitParameter("test-param"));
    The index.htm file (or the relevant portion)<HTML>
    <Head>
    <META http-equiv="Content-Style-Type" content="text/css">
    <LINK href="RTEStyleSheet.css" rel="stylesheet" type="text/css">
    <TITLE>Login</TITLE>
    </HEAD>
    <BODY>
    <FORM NAME="Login" METHOD="POST" ACTION="rte.ServletLDAP"><!-- Branding information -->
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
         <tr>
              <td width="30%" align="left"><img src="images/top_logo_new2.gif">
              </td>
              <td width="37%" align="center"></td>
              <td width="33%" align="right"></td>
         </tr>
    </table>
    My web.xml entry for the filter:     <filter>
              <description>
              Checks for a session timeout on each user request, redirects to logout if the session has expired.</description>
              <display-name>
              SessionTimeoutFilter</display-name>
              <filter-name>SessionTimeoutFilter</filter-name>
              <filter-class>SessionTimeoutFilter</filter-class>
              <init-param>
                   <param-name>test-param</param-name>
                   <param-value>this is a test parameter</param-value>
              </init-param>
         </filter>
         <filter-mapping>
              <filter-name>SessionTimeoutFilter</filter-name>
              <url-pattern>/*</url-pattern>
              <dispatcher>REQUEST</dispatcher>
              <dispatcher>FORWARD</dispatcher>
         </filter-mapping>

    Hi,
    Try adding CSS files and images to the excluded Pages.

  • Please help me i have to finish this by tonight

    Hi Herewith I have enclosed the code.. I am not sure where i am going wrong..moreover i am very new to this technologies.. i need to finish this by tonight.. anyone helps that will be great..
    here is my problem.. i need to check a rebate id which exists in the database.. if it exists I have to update the value and if doesn't exits i have to insert a new row..
    My jsp will contails 10 rows.. Once after submit.. I have to check with the database whetehr that rebate_sku_num exits.. if exits i need to update that row.. if not i have to insert a new record.. here is my code.. please give some solution.. thanks
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId="";
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");     
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ; 
    System.out.println("entering date is " +entryDate1) ; 
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    flag =true;
    if (flag) {
    // from here
    try {
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB";
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID query : " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    while (resultset.next()) {
    RebateId = resultset.getString("REBATE_SKU_NUM");
    System.out.println("the REBATE_SKU_NUM is " + RebateId);
    }else{
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID : resltset is null " );
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in getting max of adjustment id");
    exception1.printStackTrace();
    // to herer
    for (int i = 0; i < rebate_sku_num.length; i++) {
    if ((rebate_sku_num[i] != RebateId)) {
    System.out.println("get the values" +rebate_sku_num);
    System.out.println("get the values" + RebateId);
    Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
    "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
    "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
    "'" + rebate_sku_num[i] + "', " +
    "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
    "'" + amount[i] + "' , '" + user_name + "'" +
    ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
    ", '" + user_name + "'," +
    " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
    System.out.println("query is executed" +Query);
    }else if ((rebate_sku_num[i] == RebateId )){
    Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[i] + " where REBATE_SKU_NUM='" + rebate_sku_num[i] + "'";
    System.out.println("query is executed for updation" +Query);
    try {
    if (DatabaseConnection.executeUpdate(Query) == 0) {
    System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
    DatabaseConnection.rollBack();
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    break;
    } else {
    System.out.println("AddRebate : doPost() : update sucessfull");
    message = "Rebate Transactions has been updated.";
    flag = true;
    } catch (Exception ex) {
    System.out.println("AddRebate : doPost() : exception in update query");
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

    hey try this code,i made changes in ur code,ur logic wasnt good on it
    thanks hithesh
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId[];
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ;
    System.out.println("entering date is " +entryDate1) ;
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    flag =true;
    if (flag) {
    // from here
    try {
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB";
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID query : " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    int j=0;
    while (resultset.next()) {
    RebateId[j] = resultset.getString("REBATE_SKU_NUM");
    System.out.println("the REBATE_SKU_NUM is " + RebateId[j]);
    j++;
    }else{
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID : resltset is null " );
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in getting max of adjustment id");
    exception1.printStackTrace();
    // to herer
    for(int i=0; i<rebate_sku_num.length,i++){
         boolean flag=false;
         for (int j = 0; j < RebateId.length; j++) {
              if ((rebate_sku_num[i] == RebateId[j])) {
                   flag=true;//u found this id in database,so u need to update
                   break;
         if(!flag){//if not found,add into database
              System.out.println("get the values" +rebate_sku_num);
              System.out.println("get the values" + RebateId);
              Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
                   "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
                   "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
                   "'" + rebate_sku_num + "', " +
                   "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
                   "'" + amount + "' , '" + user_name + "'" +
                   ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
                   ", '" + user_name + "'," +
                   " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
              System.out.println("query is executed" +Query);
         else //if found just update the database
                   Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount + " where REBATE_SKU_NUM='" + rebate_sku_num + "'";
                   System.out.println("query is executed for updation" +Query);
         try {
              if (DatabaseConnection.executeUpdate(Query) == 0) {
                   System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
                   DatabaseConnection.rollBack();
                   message = "Some problem in updating transactions. Please try again later.";
                   flag = false;
                   break;
              } else {
                   System.out.println("AddRebate : doPost() : update sucessfull");
                   message = "Rebate Transactions has been updated.";
                   flag = true;
         } catch (Exception ex) {
              System.out.println("AddRebate : doPost() : exception in update query");
              message = "Some problem in updating transactions. Please try again later.";
              flag = false;
              ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

  • How to achive this using servlet

    hi I am new to this technology... My requirement is , First I have to check whether that rebate_sku_num exists in the database or not.. If exits i need to update the row.. If now I have to insert the new row with values.. How to achive this..
    my screen contains 7 rows... in will increase.. for every submit.. i have to check with the database.. whether the rebate_sku_num exists or not.. help me out.. here is my code.. i am not sure how to format my code.. in future i will do it...
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId="";
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ;
    System.out.println("entering date is " +entryDate1) ;
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    // from here
    flag = true;
    for (int z = 0; z < rebate_sku_num.length && flag; z++) {
    try {
    flag=false;
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB where REBATE_SKU_NUM ='" + rebate_sku_num[z] + "'";
    System.out.println("AdjustmentServlet : doGet() : checking sku validity query = " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    while (resultset.next()) {
    RebateId = resultset.getString("REBATE_SKU_NUM");
    flag = true;
    if ((rebate_sku_num[z] != RebateId)) {
    System.out.println("get the values" +rebate_sku_num);
    System.out.println("get the values" + RebateId);
    Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
    "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
    "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
    "'" + rebate_sku_num[z] + "', " +
    "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
    "'" + amount[z] + "' , '" + user_name + "'" +
    ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
    ", '" + user_name + "'," +
    " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
    System.out.println("query is executed" +Query);
    }else if ((rebate_sku_num[z] == RebateId )){
    Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[z] + " where REBATE_SKU_NUM='" + rebate_sku_num[z] + "'";
    System.out.println("query is executed for updation" +Query);
    } else {
    System.out.println("AdjustmentServlet : doGet() : checking for sku validity : resultset null");
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in checking validity of SKU");
    exception1.printStackTrace();
    // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
    message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
    flag = false;
    try {
    if (DatabaseConnection.executeUpdate(Query) == 0) {
    System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
    DatabaseConnection.rollBack();
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    // break;
    } else {
    System.out.println("AddRebate : doPost() : update sucessfull");
    message = "Rebate Transactions has been updated.";
    flag = true;
    } catch (Exception ex) {
    System.out.println("AddRebate : doPost() : exception in update query");
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

    Oh and you can give me the dukes for helping you here:
    http://forum.java.sun.com/thread.jsp?forum=45&thread=475828&tstart=0&trange=15

  • Help this poor guy

    Hi Herewith I have enclosed the code.. I am not sure where i am going wrong..moreover i am very new to this technologies.. i need to finish this by tonight.. anyone helps that will be great..
    here is my problem.. i need to check a rebate id which exists in the database.. if it exists I have to update the value and if doesn't exits i have to insert a new row..
    My jsp will contails 10 rows.. Once after submit.. I have to check with the database whetehr that rebate_sku_num exits.. if exits i need to update that row.. if not i have to insert a new record.. here is my code.. please give some solution.. thanks
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
    public void init(ServletConfig servletconfig) throws ServletException {
    super.init(servletconfig);
    public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
    throws ServletException, IOException {
    HttpSession session;
    session = httpservletrequest.getSession(true);
    String user_name;
    String divisionCode;
    String rebate_sku_num[];
    String selectedMonth;
    String amount[];
    String message = "";
    String Query="";
    String RebateId="";
    boolean flag = true;
    // from here
    Calendar todaysdate = new GregorianCalendar();
    SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
    SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");
    System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
    String entryDate = sdf.format(todaysdate.getTime());
    String entryDate1 = sdf1.format(todaysdate.getTime());
    System.out.println("entering date is " +entryDate) ;
    System.out.println("entering date is " +entryDate1) ;
    // to here
    user_name = (String) session.getAttribute("user_name");
    divisionCode = (String) session.getAttribute("division_code");
    selectedMonth = httpservletrequest.getParameter("selectedMonth");
    rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
    amount = httpservletrequest.getParameterValues("amount");
    System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
    System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
    System.out.println("AddRebate : doPost() : amount = " + amount);
    flag =true;
    if (flag) {
    // from here
    try {
    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB";
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID query : " + s);
    ResultSet resultset = DatabaseConnection.executeQuery(s);
    if (resultset != null) {
    while (resultset.next()) {
    RebateId = resultset.getString("REBATE_SKU_NUM");
    System.out.println("the REBATE_SKU_NUM is " + RebateId);
    }else{
    System.out.println("AdjustmentServlet : doGet() : getting maximum adjustment ID : resltset is null " );
    } catch (Exception exception1) {
    System.out.println("AdjustmentServlet : doGet() : exception in getting max of adjustment id");
    exception1.printStackTrace();
    // to herer
    for (int i = 0; i < rebate_sku_num.length; i++) {
    if ((rebate_sku_num != RebateId)) {
    System.out.println("get the values" +rebate_sku_num);
    System.out.println("get the values" + RebateId);
    Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
    "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
    "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
    "'" + rebate_sku_num + "', " +
    "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
    "'" + amount + "' , '" + user_name + "'" +
    ", TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
    ", '" + user_name + "'," +
    " TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
    System.out.println("query is executed" +Query);
    }else if ((rebate_sku_num == RebateId )){
    Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount + " where REBATE_SKU_NUM='" + rebate_sku_num + "'";
    System.out.println("query is executed for updation" +Query);
    try {
    if (DatabaseConnection.executeUpdate(Query) == 0) {
    System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
    DatabaseConnection.rollBack();
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    break;
    } else {
    System.out.println("AddRebate : doPost() : update sucessfull");
    message = "Rebate Transactions has been updated.";
    flag = true;
    } catch (Exception ex) {
    System.out.println("AddRebate : doPost() : exception in update query");
    message = "Some problem in updating transactions. Please try again later.";
    flag = false;
    ex.printStackTrace();
    session.setAttribute("message", message);
    httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
    return;

    Hi Here my code is, I am able to add one by one records... but if the record is there still it is trying to inser and throwing some execption. Because that rebate_sku_num is the primary key..
    I want to add multiple records.. by cecking rebate_sku_num is present in the table or not. It is not I need to insert a new row.. else I need to update the record.
    Thanks
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.servlet.SingleThreadModel;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import java.io.IOException;
    import java.sql.ResultSet;
    import java.io.*;
    import java.util.*;
    import java.util.Date;
    import java.text.*;
    public class AddRebate extends HttpServlet implements SingleThreadModel {
        public void init(ServletConfig servletconfig) throws ServletException {
            super.init(servletconfig);
        public void doPost(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
                throws ServletException, IOException {
            HttpSession session;
            session = httpservletrequest.getSession(true);
            String user_name;
            String divisionCode;
            String rebate_sku_num[];
            String selectedMonth;
            String amount[];
            String message = "";
            String Query="";
            String RebateId=""; 
            boolean flag = true;
            Calendar todaysdate = new GregorianCalendar();
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
            SimpleDateFormat sdf1 = new SimpleDateFormat("MM/dd/yyyy HH:MM:SS");     
            System.out.println("today's date: " + sdf.format(todaysdate.getTime()));
            String entryDate = sdf.format(todaysdate.getTime());
            String entryDate1 = sdf1.format(todaysdate.getTime());
            user_name = (String) session.getAttribute("user_name");
            divisionCode = (String) session.getAttribute("division_code");
            selectedMonth = httpservletrequest.getParameter("selectedMonth");
            rebate_sku_num = httpservletrequest.getParameterValues("rebateId");
            amount = httpservletrequest.getParameterValues("amount");
            System.out.println("AddRebate : doPost() : selectedMonth = " + selectedMonth);
            System.out.println("AddRebate : doPost() : rebate_sku_num = " + rebate_sku_num);
            System.out.println("AddRebate : doPost() : amount = " + amount);
       flag = true;
            for (int z = 0; z < rebate_sku_num.length && flag; z++) {
                try {
                         flag=false;
                    String s = "select REBATE_SKU_NUM from EASMSA_REBATE_SKU_DETAILS_TB where REBATE_SKU_NUM ='" + rebate_sku_num[z] + "'";
                    System.out.println("AdjustmentServlet : doGet() : checking sku validity query  = " + s);
                    ResultSet resultset = DatabaseConnection.executeQuery(s);
                    if (resultset != null) {
                        while (resultset.next()) {
                            RebateId = resultset.getString("REBATE_SKU_NUM");
                            flag = true;
            if ((rebate_sku_num[z] != RebateId)) {
                    System.out.println("get the values" +rebate_sku_num);
                     System.out.println("get the values" + RebateId);
                       Query = "INSERT INTO EASMSA_REBATE_SKU_DETAILS_TB " +
                                "( REBATE_SKU_NUM, REBATE_DATE, REBATE_AMT, CREATED_BY," +
                                "CREATION_DATE, LAST_UPDATED_BY, LAST_UPDATE_DATE ) VALUES (" +
                                "'" + rebate_sku_num[z] + "',  " +
                                "TO_Date( '" + "30/" + selectedMonth + "', 'dd/MM/YYYY HH:MI:SS AM'), " +
                                "'" + amount[z] + "' , '" + user_name + "'" +
                                ",  TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM')" +
                                ", '" + user_name + "'," +
                                 "  TO_Date( '" + entryDate + "', 'MM/dd/YYYY HH:MI:SS AM'))";
                        System.out.println("query is executed" +Query);
                  }else if ((rebate_sku_num[z] == RebateId )){
                       Query = "update EASMSA_REBATE_SKU_DETAILS_TB set REBATE_AMT=" + amount[z] + " where REBATE_SKU_NUM='" + rebate_sku_num[z] + "'";
                       System.out.println("query is executed for updation" +Query);
                    } else {
                        System.out.println("AdjustmentServlet : doGet() : checking for sku validity : resultset null");
                       // message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
                        message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
                        flag = false;
                } catch (Exception exception1) {
                    System.out.println("AdjustmentServlet : doGet() : exception in checking validity of SKU");
                    exception1.printStackTrace();
                  //  message = "SKU '" + sku[z] + "' of customer '" + customer[z] + "' and location '" + location[z] + "' is not valid.";
                   message = "SKU '" + rebate_sku_num[z] + "' is not valid.";
                    flag = false;
                   try {
                        if (DatabaseConnection.executeUpdate(Query) == 0) {
                            System.out.println(" AddRebate : doPost() : rollback: error in executing update query= " + Query);
                            DatabaseConnection.rollBack();
                            message = "Some problem in updating transactions. Please try again later.";
                            flag = false;
                           // break;
                        } else {
                            System.out.println("AddRebate : doPost() : update sucessfull");
                            message = "Rebate Transactions has been updated.";
                            flag = true;
                    } catch (Exception ex) {
                        System.out.println("AddRebate : doPost() : exception in update query");
                        message = "Some problem in updating transactions. Please try again later.";
                        flag = false;
                        ex.printStackTrace();
            session.setAttribute("message", message);
            httpservletresponse.sendRedirect("Welcome1.jsp?s=y");
            return;
    [/code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Not able to retrieve data from database through servlet

    Hi friends,
    I am trying to open a excel sheet through servlet. In this servlet i am retriving data from mssql database.I am not getting any error but no data is retrived
    i m also pasting the code here
    // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3)
    // Source File Name:   EmployeeData.java
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    public class EmployeeData extends HttpServlet
        public EmployeeData()
        public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws ServletException, IOException
            httpservletresponse.setContentType("text/html");
            httpservletresponse.setHeader("Content-Type", "application/excel");
            httpservletresponse.setHeader("Content-Disposition", "filename=reports.xls");
            PrintWriter printwriter = httpservletresponse.getWriter();
            try
                javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
                int i = 0;
             /*   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=newreportsodbc", "reportuser", "cisco");*/
                String url="jdbc:odbc:newreportsodbc";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:odbc:newreportsodbc","reportuser","cisco");
                Statement statement = connection.createStatement();
                printwriter.println("<b><center><u> Search Results </u></center></b>");
                printwriter.print("<table><tr><th color=brown background-color=#fff000>  No.  </th>");
                printwriter.print("<th> DateTime      </th></tr></table>");
           ResultSet resultset = statement.executeQuery("SELECT * FROM t_Call_Type_Half_Hour");
                boolean flag;
                for(flag = false; resultset.next(); flag = true)
                    i++;
                    SerialNo = resultset.getString(2);
                    printwriter.print((new StringBuilder()).append("<table><tr><td> ").append(i).append("</td>").toString());
                    printwriter.print((new StringBuilder()).append("<td> ").append(SerialNo).append("</td></tr></table>").toString());
                if(!flag)
                    printwriter.println("<h1> No records selected </h1>");
            catch(Exception exception)
                System.out.println((new StringBuilder()).append("SQLException: ").append(exception).toString());
        static String empid1;
        static String empid;
        static String SerialNo;
        static String designation;
    }thanks in advance. i just feel there is something to be done with connection string.

    post the table format in SQL

  • How to create a new session in JSP file

    Usually a child IE window uses same session with parent window. Dose someone know how to create a new session when creating a new IE window by clicking a URL in parent window? The web page is writen by jsp file.

    I am not sure of your question. Are you wanting to have 2 Session objects (one for the parent window and another for the child)?
    A session is usually created once per client and is stored on the server the session id is carried around in a cookie or a URL rewrite so that everytime the user submits a page you will be able to store/access information.
    // this will create a new session object if one doesn't already exist.
    HttpServletRequest.getSession( true );
    Hope this helps

  • Issue with Session ID during POST

    Hi All,
    I am using Weblogic server version weblogic 9.2 and facing an issue with the session ID.
    I have a client side script with numerous GET calls and one POST call that it makes in a single session. Frequently I come across with issue that the session ID that I send in POST request is not the same as received and this affects my subsequent GET calls not to be in the same session. The call order is like this
    GETij/POSTij where i is the sent and j is the recieved session IDs.
    [GET11, GET11, GET11, POST12, GET11, GET11, <after few secs interval> GET22, GET22]
    I store the session id in a cookie. And I always create a session using the HttpServletRequest.getSession();
    Can some one advice on this.
    Thanks
    Shankar

    Hi,
    Again as a follow-up, I am using net scape ns plugin for load balancing (iPlanet/Weblogic). The issue happens when the primary server id and the secondary server id are same in the session id (set in the cookie) when the cookie is sent and received, where session id is of the default format <session id>!<primary server id>!<secondary server id>
    Any clue?

  • Is a Servlet-Filter which serializes requests in the same user session ok?

    The Servelt specification states that the Web-Application is itself responsible for synchronizing access to HttpSessions. It is from the serversite not possible to prevent multiple threads to access the same HttpSession (i.e. the user could always open a second window, retransmit a form etc). My assumption is that while this does not happen often it can happen and therefore I think each access to the HttpSession must be synchronized. For a further discussion see http://forum.java.sun.com/thread.jsp?forum=4&thread=169872 .
    Concurrent programming is generally complicated and errorprone. At least in developing JSPs it is inconvenient and easy to forget. My Web-App uses often HttpSession and it can be used in different not predefined places, so I had the idea to implement a ServletFilter which serializes threads which happen in the same session. This involves certainly some overhead. However for the advantages of easier code maintains and higher consistency I am ready to pay this overhead.
    My question is generally what you think of this approach and second whether the way I implemented the Filter works.
    The Filter actually generates for each Request an HttpServletRequestWrapper which intercepts calls to getSession and on call aquires a Lock so that other threads have to wait for the same Session. The lock is released when the doFilter method of the Filter returns. So threads run concurrently until the first access to the Session and from there they are serialized until the end of the Request.
    For the details I will give the code for the Filter and the Wrapper (that?s all the code needed except the ReentrantLock which is Doug Lea?s implementation http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html )
    the Filter
    public class SessionThreadFilter implements Filter
      public static final String MUTEXT_IN_SESSION_KEY = "org.jaul.filter.SessionThreadFilter.MUTEX";
      //constructor, init, destroy methods do nothing
      public void doFilter(ServletRequest reqIn,ServletResponse res,FilterChain filterChain)
        throws IOException, ServletException
        //if req not instanceof of HttpRequest don't do anything
        if (!(reqIn instanceof HttpServletRequest))
          filterChain.doFilter(reqIn, res);
        } else
          HttpServletRequest req = (HttpServletRequest) reqIn;
          //We use a HttpRequestWrapper each time a user accesses
          //through this
          //Wrapper a Session is Lock is aquired. The filter method returns
          //the lock if it exists is released
          //each thread needs it's own wrapper so the wrapper itself
          //doesn't have to be synchronized
          SessionThreadRequestWrapper wrapper = new SessionThreadRequestWrapper(req);
          try{
            filterChain.doFilter(wrapper, res);
          }finally{
            ReentrantLock lock = wrapper.getLock();
            if (lock != null && lock.holds() != 0)
                       lock.release(lock.holds());
    the Wrapper
    final public class SessionThreadRequestWrapper extends HttpServletRequestWrapper {
      private ReentrantLock lock = null;
       * Constructor for SessionThreadRequestWrapper.
       * @param arg0
      public SessionThreadRequestWrapper(HttpServletRequest req){
        super(req);
       * @see javax.servlet.http.HttpServletRequest#getSession()
      public HttpSession getSession(){
        return getSession(true);
       * @see javax.servlet.http.HttpServletRequest#getSession(boolean)
      public HttpSession getSession(boolean construct){
        //this will get the session an the lock
        HttpSession session = getLockFromSession(construct);
        if (session == null) return null;
        //get a lock on the mutex
        try{
          lock.acquire();
        } catch (InterruptedException e){
          throw new IllegalStateException("Interrupted while thread waiting for session");
        //now we check again if the session is still valid
        try{
          session.getAttribute(SessionThreadFilter.MUTEXT_IN_SESSION_KEY);
        } catch (IllegalStateException e){
          //again we go recusively but first release the lock
          lock.release();
          lock = null;
          return getSession(construct);
        //after you got the lock you can return the session
        return session;
       * gets the lock from the session
       * @param construct
       * @return HttpSession
      private HttpSession getLockFromSession(boolean construct){
        //test if it is a new Session
        HttpSession session = super.getSession(construct);
        //if is null no session was realy requested
        if (session == null) return null;
        //otherwise try to get the lock if necessery construct it
        //syncrhonized over session
        synchronized (session){
          //this migth throw an Exception if the session has been
          //invalidated in the mean time
          try{
            lock = (ReentrantLock) session.getAttribute(SessionThreadFilter.MUTEXT_IN_SESSION_KEY);
            if (lock == null){
              lock = new ReentrantLock();
              session.setAttribute (SessionThreadFilter.MUTEXT_IN_SESSION_KEY, lock);
            return session;
          } catch (IllegalStateException e){
            //the session has been invalidated before we tried to get the
            //lock we recursively call getLockFromSession
            //( assumption checked with Jetty: if the session is invalidated
            //and getSession is called on the thread a new valid session
            // should is returend)
            //I hope sometime you should get a valid session but I am not
            //sure. This is crucial for breaking of the recursion
            lock = null;
            return this.getLockFromSession(construct);
      /** used by the Filter to get the lock so that it can release it
      ReentrantLock getLock(){
         return this.lock;
    }As stated I would be very thankful if you could check the code and give some commends.

    synchronized (session){Are you sure that the session instance returned by two
    concurrent calls to getSession(...) are the same? I
    think that tomcat for instance may return different
    instances for the same "logical " session, which would
    break your scheme I think... Thank you (I did not know that on Tomcat). The same thing could also occur if another filter wrapped the Session.
    That's indeed a problem,which I have already adressed in another thread, but did not get an answer. ( http://forum.java.sun.com/thread.jsp?forum=33&thread=412380). The already cited thread http://forum.java.sun.com/thread.jsp?forum=4&thread=169872 adresses the same problem, but the discussion there ends with the recomandation that you should synchronize on HttpSession as I did it. Also in other forums I've read so.
    However like you I've at least strong doubts in this approach, so now my question is on what should I than generally for any access in any web-app syncrhonize the access to Http-Session as demanded by the Servlet specs.
    A few not realy satisfying answers:
    Synchronize on the HttpSession itself: I think still the best approach, but as you say is it guaranteed that the same instance of an HttpSession is given to each Request (in one Session)?
    Synchronized on the HttpServlet: This only works if no other servlet (or jsp) accesses in the session the value with the same key ( of course only if the session itself is threadsave). In case of ThingleThread it is not possible at all there can be multiple instances (you could use a static variable)
    Holding the object to synchronize on in applicaton scope or session scope: This obiously doesn't help, because somehow you have to obtain the lock and at least there you need another synchronize.Holding in application socpe is slow a static variable lock would be better there.
    Synchronize on some static variable: This will work, but is very slow (each request not only in the same session would synchronize on this).
    Hold a map in application scope, which holds for each Session-key a lock: Is probably faster than the static variable thing. However the access and the management of the Map (removing of unused locks etc.- Mabe you could use a WeakHashMap to collect the locks for not used keys anymore) is time consuming too and again the map must be accessed syncrhonasly by all requests.
    Syncrhonize on the Filter (only in my case): This is as slow as the static variable approach because each request will use the same lock the one instance of the Filter.
    So synchronizing on the session is propably the best approach if the same attribute name is accesed by different servlets. However if you say that some Web-Containers return different HttpSession instances for the same Session (which is legal according to the specification) this of course does not work.
    So I have realy no clue on what to syncrhonize than. Now help is not only neede on my Thread serialization filter but on my generally Servlet prgromming.
    May be you could help me for another synchronization aproach.

  • Html:select - very confusing

    I am having a lot of difficulty understanding how the html:select works - especially if you're working with different ypes of containers e.g. hashmaps, lists, collections. I'm especially having trouble with lists. Here's what I have (I'm building a struts application):
    Action Class
    List bdates = dbconfig.getBusinessDates();
    httpServletRequest.getSession().setAttribute("BusinessDates", busDates );JSP Page
    <%@ page import "import java.util.List" %>
    <%
    List getBusDates = (List) session.getAttribute("BusinessDates");
    request.setAttribute("busDate", getBusDates);
    %>
    <html:select property="businessdate">
            <html:options collection="busDate" property="bdate"/>
    </html:select>I get an error saying no get property found for bdate in bean. So then I manually go to my ActionForm for this JSP page and add bdate as a string variable and its getter and setter functions. But it still doesnt work.
    Can someone please explain to me how I can use a List with an Html:select and html:option tags in JSP?
    Any assistance much appreciated.

    1) There's no need to pull the collection out of the session and put it in the request...
    <html:options collection="BusinessDates" scope="session" property="bdate" labelProperty="bdateLabel" />
    2) The property and labelProperty values are used to map to fields in the objects that are in the list. It doesn't matter what is in the list, as long as those classes have methods:
    public String getBdate() {
       return ...;
    public String getBdateLabel() {
       return ...;
    }

Maybe you are looking for

  • Mobile Hotspot not working after upgrading to official version OS10.3.1.1​​565

    Dear Support, I am facing the issue with my device Q10 when i have upgraded the version to OS 10.3.1.1565. The mobile plan is 6 Gb so no issues from this side. Please we need a solution for this problem, it was working fine bfore the update. Thank Yo

  • Can you install 16gbs of ram in a 2012/2013 non retina macbook pro?

    the newest non retina macbook pro on the apple website. the reason im asking is that apple only offers 4gbs and 8gbs. does apple not sell 16gbs of ram on the macbook because of price or does the computer not support it? im getting the 2.9GHz dual-cor

  • Re: Reports for Sites

    Hey there, you are talking about IS Retail - just making sure??? First of all: There is no support from SAP about "internal" reporting within IS Retail anymore. Meaning: You are using the RIS (Retail information system) INSTEAD/or in parallel - of BW

  • Customer contact in collections

    Hi gurus, I have created in customer master data information about customer (name, fax, email...). When I transfer a customer to a business partner this information appears. My question is: In UDM_SUPERVISOR, how can you see this information that I i

  • Modelling Exclusive Arcs in Designer?

    Is this possible? I know designer can take an Arc approach to modelling sub and super types.. but an 'exclusive' arc is based on different principles? Cheers...