HttpServletResponse.sendRedirect()

I'm migrating a web app from Weblogic 8 to 10.3. The setup is:
Apache 2.2 is used for static html (e.g. myserver/foo.html).
Apache Weblogic plugin is used to send servlet/JSP requests to the weblogic container, if the URL contains the prefix /weblogic (e.g. myserver/weblogic/foo.jsp). PATHTRIM is being used to strip out the /weblogic.
My problem arises when a JSP tries to redirect back to Apache for static content, e.g.
myHTTPServletResponse.sendRedirect("/foo.html");
The URL that is being generated is myserver/weblogic/foo.html which isn't found (since static content lives under Apache, so shouldn't have the /weblogic prefix ).
The J2EE doc says "the servlet container must convert the relative URL to an absolute URL before sending the response to the client. .... If the location is relative with a leading '/' the container interprets it as relative to the servlet container root. " I'm at a loss as to why the string "/weblogic" should be perceived as part of the container root... since supposedly, that string had been trimmed in Apache (by the plugin).
I can revise my JSP to redirect to an absolute URL, but I am reluctant to do so because this particular feature seems to work fine in WL8. Feels like a minor flaw in my WL10 configuration... can anyone help me isolate the problem? What am I missing here?
TIA,
Ken

sorry I posted in the wrong area. Please ignore this post!

Similar Messages

  • HttpServletResponse.sendRedirect bug in Release 2

    I think I've come across a bug with the HttpServletResponse.sendRedirect() method and OC4J in 9iAS R2.
    I've constructed the following statement:
    response.sendRedirect("http://www.myurl.com/index.jsp?src1=http://www.abc.com&src2=http://www.somewhere.com
    What happens when the servlet containing this method is invoked is the redirect attempts to connect to:
    http://www.myurl.com/index.jsp?src1=http:/www.abc.com&src2=http:/www.somewhere.com
    The double forward slashes in the query string portion of the request URL are replaced with a single slash!
    I've tested this on different R1 and 10g OC4J versions and it works perfectly. The bug only arises in R2. Unfortunately for me, I have to get this working in an R2 environment.
    Has anyone come across this problem before, and worked around it?
    Thanks very much in advance.
    Lawrence

    Vikas,
    all clear but that v('P102_ID') call is bothering me!
    And other thing....I was debugging in first function (with number parameter)...and if API is making VARCHAR2 value, then in no circumstances first function (with number) cannot be called but only second one (with two VARCHAR2)...which was not called !!!!
    To make more clear, create two function (in this order in package):
    FUNCTION update_password (
                p_id       IN HTMLDB_USERS.ID%TYPE
               ,p_password IN HTMLDB_USERS.PASSWORD%TYPE
              ) RETURN PLS_INTEGER;
    BEGIN
      dbms_output.put_line(v('P102_ID'));
      dbms_output.put_line('Number called function "'||to_char(p_id)|'"');
      return null;
    END;
    FUNCTION update_password (
                p_username       IN HTMLDB_USERS.USERNAME%TYPE
               ,p_password IN HTMLDB_USERS.PASSWORD%TYPE
              ) RETURN PLS_INTEGER;
    BEGIN
      dbms_output.put_line(v('P102_ID'));
      dbms_output.put_line('VARCHAR2 called function "'||p_username||'"');
      return null;
    END;and make a call like in my case.
    This is most interesting of all! Intersting which function will be called!
    Maybe this note helps someone to be mislead...
    Message was edited by:
    Funky

  • 6.1 SP5: response.sendRedirect crashes

    Hi all,
    I am porting a JSP app from Iplanet 4.1 to SunONE 6.1 SP5 (Solaris 5.9).
    When I try to do the above statement in a JSP, I get the following in the error log:
    [14/Jun/2007:16:05:05] failure ( 3812): for host 172.16.10.184 trying to POST /jspcontent/ozbet.jsp;jsessionid=43DBC3EA6343C4B0E3BF6AD26B943D25, service-j2ee reports: StandardWrapperValve[jsp]: WEB2792: Servlet.service() for servlet jsp threw exception
    java.lang.IllegalStateException
    at org.apache.catalina.connector.HttpResponseFacade.sendRedirect(HttpResponseFacade.java:179)
    at jsps.jspcontent._ozbet_jsp._jspService(_ozbet_jsp.java:109)
    at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    at com.iplanet.ias.web.jsp.JspServlet$JspServletWrapper.service(JspServlet.java:687)
    at com.iplanet.ias.web.jsp.JspServlet.serviceJspFile(JspServlet.java:459)
    at com.iplanet.ias.web.jsp.JspServlet.service(JspServlet.java:375)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:908)
    at org.apache.catalina.core.StandardWrapperValve.invokeServletService(StandardWrapperValve.java:771)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:322)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:212)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:209)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:509)
    at com.iplanet.ias.web.connector.nsapi.NSAPIProcessor.process(NSAPIProcessor.java:161)
    at com.iplanet.ias.web.WebContainer.service(WebContainer.java:580)
    I am not sure what I need to declare differently in 6.1. The web app jars are in WEB-INF/lib under the docroot.
    The code in the JSP is pretty standard, but ran under Iplanet 4.1.
    try {
         String URL = "https://www.ozbet.com.au/tab/ozbet.htm?p_date=" //has parameters;
    response.sendRedirect(URL);
    catch (ApplicationException e) {
         //do some stuff here
    %>
    <b>ERROR:</b> <%= msg %>"
    <%
    FYI the webapp is working fine wrt to jdbc, jsp etc. It is just the sendRedirect() that is crashing.
    Do I need to declare anything related to NSAPI in obj.conf ?
    Please help and thanks in advance.
    Richard
    Message was edited by:
    r_defonseka
    Message was edited by:
    r_defonseka

    That's not a crash. HttpServletResponse.sendRedirect is throwing an IllegalStateException because you called it after the response had been committed. This is a documented part of the Servlet spec. (See, for example, http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponse.html#sendRedirect(java.lang.String) for the the J2EE 1.3 docs.)
    The most likely problem is that you're calling sendRedirect after an include or after outputting too much data. If you're going to call sendRedirect, you need to do so near the top of your JSP file, before you output a lot of data. Once data has been sent to the client, there's no way for the server to say "oops, never mind, ignore that data and redirect over here instead".

  • SendRedirect throws exceptions

    Occasionally when invoking HttpServletResponse.sendRedirect to a good URL, the method throws java.io.IOException stating "response contains no data" or "socket reset by peer". What can cause this error and how do you fix it?
              

    Hi.
              What version/service pack level of WLS are you running? What platform? Can you characterize this any further? Happens under load, or purely random?
              Thanks,
              Michael
              Eric Gufford wrote:
              > Occasionally when invoking HttpServletResponse.sendRedirect to a good URL, the method throws java.io.IOException stating "response contains no data" or "socket reset by peer". What can cause this error and how do you fix it?
              Michael Young
              Developer Relations Engineer
              BEA Support
              

  • 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]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How can I redirect to an URL from a portlet?

    I'm using Bea Workshop 8.1 and trying to perform a redirect from inside a portlet
    using HTTPServletResponse.sendRedirect(String url)... but nothing happens ((
    I tryed the same trick with a simple JSP, and that's ok, but portal pages obviously
    catch the redirect somehow.
    Please could you tell the correct way of redirecting the whole browser to another
    page from inside portlets?
    Thanks!!!

    Backing files is an option. If you need to do it from the controller, you
    could use the Forward object. The forward object constructor can take a URL
    object as a parameter. This should do the trick.
    Regards,
    Kunal
    "Panji Aryaputra" <[email protected]> wrote in message
    news:[email protected]..
    Hi, you have to use backing file to get what you want. In my case, I am
    using a page backing file. Perhaps a portlet backing file can do thatalso.
    Cmiiw, the redirect header makes the page redirected only if the httpheader
    has not been sent to client. In your case, the header has been sent (i.e.
    the portal header.jsp has been displayed, etc). So the header need to be
    sent before anything else sent to client browser. This is where thebacking
    file comes handy.
    hth
    panji.a
    "A Hagen" <[email protected]> wrote in message
    news:[email protected]..
    I'm using Bea Workshop 8.1 and trying to perform a redirect from inside
    a
    portlet
    using HTTPServletResponse.sendRedirect(String url)... but nothing
    happens
    I tryed the same trick with a simple JSP, and that's ok, but portal
    pages
    obviously
    catch the redirect somehow.
    Please could you tell the correct way of redirecting the whole browser
    to
    another
    page from inside portlets?
    Thanks!!!

  • How can I forward a file in Servlet

    I have three files
    1. form
    2. Error file
    3. Success file
    I want when first file sent data into db if this is inserted then goto file3 else file2
    putting coditions is not problem but don't know the syntax to auto forward towards the desired file
    plz help me. Thanks

    I think the HttpServletResponse.sendRedirect(String loc) will solve ur problem.
    If not then check out the servlet api docs.

  • File download from a portletized ADF app running in webcenter spaces.

    Hi,
    I am having trouble downloading non static files from a portletized(with ADFPortletBridge) ADF application running as a portlet producer in Webcenter spaces .
    This is my scenario :
    Jdev : 11.1.1.3
    Webcenter : 11.1.1
    The ADF app has a query page, that uses the af:query component to do a query and display results on a table. This table data need to be exported as a file with some changes like splitting address to component city and state columns .
    The ADF app makes use of af:filedownloadlistener to get this(HTML formatted file with an .xls ext is our current preference to get it to open in excel, but could be anything) done . The ADF app works just fine, but as section 30.2.5.5 in the web center dev guide points out http://download.oracle.com/docs/cd/E14571_01/webcenter.1111/e10148/jpsdg_bridge.htm#CACBHDEF
    > The <af.fileDownloadActionListener> component is not supported.
    The actual behavior however is that the export happens when triggered, but the component keep serving up the same file it created the first time it got invoked every subsequent time. The same file is served even across sessions.
    The alternatives I've considered so far are :
    1. <af:exportCollectionActionListener> - Exports what you see on the UI table. Would not work for us, because our exported data is different than whats on screen. (eg: whole addresses are displayed as a single column, but broken down as component city and state columns in exported data )
    UPDATE : <af:exportCollectionActionListener> exhibits the same behavior as <af.fileDownloadActionListener> in a portlet environment. The first time after deployment it works, and every subsequent time (across sessions) it serves up the same file it first generated.
    2. redirect to a servlet - admittedly half baked idea - fiire an action that will generate the report, then put it in sessionScope , redirect to a servlet that would pick up the report from session and stream it to the user by setting the servlet's response content type. Very unsure if this would fly in a portlet environment (sorry, I'm new to portlets) and even if it does, section 30.2.5.2 in the web center dev guide says :
    Do not redirect or forward a request within your JSP. JSR 168 only supports requestDispatcher.include(). The use of httpServletResponse.sendRedirect() or requestDispatcher.forward() results in exceptions and errors. Am I overlooking some feature that would let me do this or whats the recommended method to achieve this functionality of exporting a file generated at run-time in a portlet environment ?
    Edited by: Jeevan Joseph on Oct 14, 2010 1:02 PM

    I'm facing the same problem. Do you have any news on this issue?

  • Get JSF objects in a Filter Class

    Hi! I have a problem with my JSF application. As the most of the web applications I have a login at the begining and I place a Listener - Filter classes for catching the session timeout to returning the user to the login page. All this works OK. The problem it´s to validate that the user only has 1 session open at the time, when the user begin session I change a flag into it's database row, and when the user logout the flags change again to false (both actions (login and logout) was fired by the user clicking it's respective buttons), this works fine, but I want to change the data flag in the database row with the timeout Filter classes after pass 1 minute. My Filter class it's like this:
        public void doFilter(ServletRequest request,ServletResponse response, FilterChain filterChain) throws IOException,ServletException {
            if ((request instanceof HttpServletRequest) && (response instanceof HttpServletResponse)) {
                HttpServletRequest httpServletRequest = (HttpServletRequest) request;
                HttpServletResponse httpServletResponse = (HttpServletResponse) response;                      
                if (!StringUtils.contains(httpServletRequest.getRequestURI(), "welcomeJSF.jsp")) {                                
                    if((httpServletRequest.getRequestedSessionId() != null) && !httpServletRequest.isRequestedSessionIdValid()){
                         /* 1 */               
                           FacesContext context = FacesContext.getCurrentInstance();
                             User user = (User) context.getExternalContext().getSessionMap().get("simpleUser");
                             UserDAO conn = new UserDAO();
                             List users = conn.findByNumber(new Long(user.getNumber()));
                             persistence.User userDB = (persistence.User) users.get(0);
                             userDB.setUse(false);
                             Transaction tx = conn.getSession().beginTransaction();
                             conn.save(userDB);
                             tx.commit();
                             conn.getSession().close();                                     
                             /* 2 */                     
                        String timeoutUrl = httpServletRequest.getContextPath()+ "/faces/" + "welcomeJSF.jsp";
                        System.out.println("Session is not invalid. Redirecting to login page. ");
                        httpServletResponse.sendRedirect(timeoutUrl);
                        return;
            filterChain.doFilter(request, response);
        }When I comment from 1 to 2 works fine, but if I want to get the context.getExternalContext().getSessionMap().get("simpleUser") i get this error:
    java.lang.NullPointerException
         at validadores.SessionTimeoutFilter.doFilter(SessionTimeoutFilter.java:53)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
         at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
         at java.lang.Thread.run(Thread.java:619)This is because I'm working in a diferent conexts? How can I get Jsf objects from ServletRequest? or to pass getExternalContext().getSessionMap() to the filter class? Any ideas to change the database when the session timeouts if I'm using hibernate?
    Thanks for your time and help!

    correction :
    MyObjectProxy extends ObjectProxy{
         override callProperty(
              // your dyna logic
    and expose new MyObjectProxy(dynaInstance)

  • Problem in Using an URL in Exit Plug (NW 2004s SP12)

    Hi,
    I have a Webdynpro application to specify the terms and conditions for the users when they login to the portal for the first time.
    Upon Accepting the terms by the user, i used to loggoff the user and will redirect to the portal logon page again to relogin. (This was a requirment )
    I was using an exit plug with the URL pointing to loggoff.jsp which invalidates the session and redirect to the portal login page again. This was working fine in NW 2004.
    The code used to call the exit plug in the Window Interface view is,
    <b>wdThis.wdGetTermsandConditionsWindowInterfaceViewController().wdFirePlugToPortal("/globalportal/web/logoff.jsp");</b>
    When we upgarded into 2004s SP12 i am getting the folllowing error when firing the exit plug with the URL.
    <b>"The Exit Plug can not use an URL when used in Portal, use Portal Navigation instead"</b>
    We tried portal navigation as well, but seems that will work with PCD Objects only, where we need to redirect to the URL(logoff.jsp).
    I tried the HttpServletResponse.sendRedirect() as well, but the control remains in the TermsandConditions view only.
    <b>Code Used:
    WebCallback  webcallback = new WebCallback();
    HttpServletResponse response= webcallback.getResponse();
    response.sendRedirect(URL);</b>
    Please let me know if somebody faced this issue and the work around for this.
    My requirement is that upon clicking on the Accept button, i need to logoff the user by calling logoff.jsp will be destroy
    the session and redirect to portal login page.
    Please let me know the work around to call the URL in the view.
    Appreciate your reply.
    Thanks and Regards,
    Sekar

    Hi
    Try
    WDClientUser.forceLogoffClientUser(null);
    url - the URL of the page that is shown to the user after logoff was done. If the parameter is null, the redirect is done to the "LogoffURL" URL that can be specified in the application properties. If this URL is also not defined, a redirect to a Web Dynpro internal logoff page is done.
    So you may either accept default logoff-page (just text "Web Dynpro application terminated. Good bye!" or provide your own page via application properties).
    Next, it is impossible to just log-off to auth screen. It is necessary to set as log-off URL some application that requires authentication also.
    This way WD will first log-off user, then shows auth-screen and then login him again to the target application.
    So try the following:
    In NW IDE open your application properties, and add standard property "log-off URL", for example "/useradmin/userAdminServlet?userProfileView";
    Regards
    Ayyapparaj

  • How to deny an ip to visit webapp and redirect to a specific page in Tomcat

    Hello,
    I need to use tomcat to deny some ips:
    <Context path="" docBase="${catalina.home}/webapps/ROOT">
         <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="202.106.186.*,202.108.36.*,202.108.44.*,202.108.45.*,202.108.5.*,202.108.9.*,220.181.12.*,220.181.13.*,220.181.14.*,220.181.15.*,220.181.28.*,220.181.31.*,222.185.245.*,202.165.100.*,220.181.19.*,159.226.50.*,202.108.11.*,202.108.22.*,202.108.23.*,202.108.249.*,202.108.250.*,61.135.145.*,61.135.146.*,64.124.85.*,61.151.243.*,202.165.96.*,216.239.33.*,216.239.35.*,216.239.37.*,216.239.39.*,216.239.51.*,216.239.53.*,216.239.55.*,216.239.57.*,216.239.59.*,64.233.161.*,64.233.189.*,66.102.11.*,66.102.7.*,66.102.9.*,66.249.64.*,66.249.65.*,66.249.66.*,66.249.71.*,66.249.72.*,72.14.207.* ,61.135.152.*,65.54.188.*,65.54.225.*,65.54.228.*,65.54.229.*,207.46.98.*,207.68.157.*,194.224.199.*,220.181.8.*,221.239.209.*,217.212.224.*,219.133.40.*,202.104.129.*,61.135.157.*,219.142.118.*,219.142.78.*,61.135.132.*,220.181.26.*,220.181.19.*,61.135.158.*,66.196.90.*,66.196.91.*,68.142.249.*,68.142.250.*,68.142.251.*,202.165.102.*,202.160.178.*,202.160.179.*,202.160.180.*,202.160.181.*,202.160.183.*,72.30.101.*,72.30.102.*,72.30.103.*,72.30.104.*,72.30.107.*,72.30.110.*,72.30.111.*,72.30.128.*,72.30.129.*,72.30.131.*,72.30.133.*,72.30.134.*,72.30.135.*,72.30.216.*,72.30.226.*,72.30.252.*,72.30.97.*,72.30.98.*,72.30.99.*,74.6.74.*,202.108.4.*,202.108.4.*,202.108.33.*,202.96.51.*,219.142.53.*"/>
    </Context>
    this ip is some spiders, but my manager need me to redirect those spiders to a specific page like index.jsp (which is not at the same tomcat server).
    It is very appreciated if you could give some advise,Thanks a lot!

    Implement a Filter which compares HttpServletRequest#getRemoteAddr() with the blacklist and map this filter on /*.
    You can issue a redirect using HttpServletResponse#sendRedirect().

  • JSF error handling

    jsf impl version 1.1
    When loading a jsf with (http GET), I am sending a get-parameter (ID=123). When resolving this in the domain model, this might cause an exception which needs to be handled. How do I correctly redirect to an error page in this case?
    Regards
    tnilsen

    Depends on business requirements. You can define an error-page for specified exception (sub)classes in web.xml. But you can also invoke HttpServletResponse#sendRedirect() to the desired page. Or simply use h:message / h:messages to display a message.

Maybe you are looking for

  • Office 2013 Professional Plus - error 1653

    Hi I tried to install Office 2013 Professional Plus 64 bit on my Windows 8.1 Update 1 pro 64 bit Lenovo Thinkpad E530. The MSI crashes after I deselected Lync and OneDrive for Business and selected Organigram for Powerpoint with the error code 1653 s

  • How can we copy personalization from one to an othere resp/function

    guys, As we use people and maintain function to maintain employee information, in this function we have made personalization and working fine, but after restricting function which is appearing on others button like (absence, qualification, previous e

  • Photoshop CC crashing on move tool

    So I've recently downloaded the new CC stuff, most of which is AWESOME!  ...However, now I've got a major problem.  I try to use photoshop CC and it crashed EVERY single time I click the move tool, no matter what document I have open.  I haven't been

  • Error handling for a save button

    hi. how do i get error handling say in a button, and then to give an error to the user, without crashing the whole application. can any one point me to any articles, tried searching , and not finding wxactly what i am looking for. thanks. http://star

  • WAP4410N Access Point wall-mountable?

    Hello everybody, I have a little question regarding the WAP4410N access point. Is it possible to mount this access point at a wall or a ceiling? Are there any little "holes" at the back of the access point for mounting? Or is there a "mounting-bracke