Response object in JSP Dyn page

Hi SAP EP Gurus,
I want to use response.setStatus() mehtod in jspdynpage but it is not working as expected. I am able to use other methods of response object like response.write().
As per my knowledge if i set response.setStatus(200) is should send error to client but it is not seding error.
It is working as same for both response.setStatus(200) and response.setStatus(500).
Is there any special way to use response.setStatus() in portal? It is working as expected in normal jsp application.

I tried but had no luck. Below is my JSPDYNPAGE code...
<%@ page import="javax.servlet.http.HttpServletResponse" %>
<%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
<HTML>
     <head>
     </head>
     <body>
<%
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
HttpServletResponse servletResponse = request.getServletResponse(true);esss
servletResponse.setStatus(500);
%>
          </body>
     </HTML>
It is not working showing portal run time error

Similar Messages

  • Where to mention the IP address in a  JSP dyn page

    Hi ,
    I am creating a mail sending system with Javamail.
    Created the JSP dyn page,
    wrote the event handler in the java file. and all.
    now I have to mention the IP address of the SMTP server.
    where should I do this....
    inside the event handler itself?
    Thanks in advance.

    Hi
    The button tag in the jsp looks like this
    <hbj:button
            id="sendEmail"
            text="sendEmail"
            width="125px"
            tooltip="Click here to send mail"
            onClick="sendEmail"
            disabled="false"
            design="STANDARD"
            />
    The function to handle the button eventing occurs in the dynpage  . The function looks like
    public void sendEmail (Event event) { ..coding.. }
    Now when the button is clicked, the control is transferred to this event handler sendEmail and the code with init starts executed.
    Hope it is clear...
    Regards,
    Ganesh N

  • Problem accessing exception object in jsp error page - Apache Tomcat 5.0.25

    Hi all,
    I'm thoroughly confused and need some help. I've deployed a very simple web application in Apache Tomcat 5.0.25 to test exception handling - errortest.jsp and error.jsp. errortest.jsp throws a divide by zero exception if executed with default values in text fields.
    When I put the directive IsErrorPage="true" in error.jsp i get a HTTP 500 error when error.jsp is accessed. If I remove it error.jsp is displayed but I cant access the exception object - if I try to I get an exception below:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 5 in the jsp file: /error.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    E:\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\mywebapp\org\apache\jsp\error_jsp.java:46: cannot resolve symbol
    symbol : variable exception
    location: class org.apache.jsp.error_jsp
    out.print(exception.getMessage());
    ^
    1 error
    Below is the code for the two jsp pages:
    errortest.jsp:
    <%@ page errorPage="error.jsp" %>
    <html>
    <head><title>Error test</title></head>
    <body>     
         <form action="errortest.jsp" method="post">
         Enter first number:<input type="text" name="first" value="5"/><br>
         Enter second number:<input type="text" name="second" value="0"/><br>
         <input type="submit"/>
         </form>
         <%
         if (request.getMethod().equals("POST")) {
              int first = Integer.parseInt( request.getParameter( "first" ) );
              int second = Integer.parseInt( request.getParameter( "second" ) );
              int answer = first/second;
         %>
    </body>
    </html>
    NB: I am able to catch and display the exception if I use a try/catch block around the division as shown below.
    try {
    int answer = first/second;
    } catch( Exception e) {
    e.printStackTrace( new PrintWriter(out) );
    error.jsp (first draft)
    NB: HTTP 500 error occurs when directive "isErrorPage" is added:
    <%@ page isErrorPage="true" %>
    <html>
    <head><title>Error Page</title></head>
    <body>
    </body>
    </html>
    error.jsp (second draft)
    NB: directive is removed but exception thrown when implicit exception object is accessed. error.jsp displays if exception object is not accessed:
    <%@ page %>
    <html>
    <head><title>Error Page</title></head>
    <body>
    <%=exception.getMessage()%>
    </body>
    </html>
    Web server specs:
    Apache Tomcat 5.0.25
    Machine specs:
    Windows XP Pro
    Java environments:
    j2sdk1.4.2_03
    J2EE 1.4

    This works for me:
    throwError.jsp
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <%@ page language="java" errorPage="/error.jsp"
    contentType="text/html; charset=utf-8" %>
    <html>
    <head>
         <title>Throw Exception</title>
    </head>
    <body>
    Throwing exception....
    <%
    // throw ArithmeticException
    int badInt = 12/0;
    %>
    </body>
    </html>
    error.jsp
    <%@ page language="java" isErrorPage="true" %>
    <head><title>Doh!</title></head>
    An Error has occurred in this application.
    <% if (exception != null) { %>
    <pre><% exception.printStackTrace(new java.io.PrintWriter(out)); %></pre>
    <% } else { %>
    Please check your log files for further information.
    <% } %>

  • Get response message in JSP error page

    Hi,
    Here's a simple one for someone. I HAVE been searching everywhere for the answer but its one of those things I just cant seem to find.
    If I call response.sendError(SC_FORBIDDEN, "Invalid roles"); from a servlet or filter, how can I retrieve the message "Invalid roles" in my JSP error page? (which I have mapped to 403 errors in web.xml).
    Its so simple yet I cannot figure out how to do it.
    Thanks in advance,
    Robert.

    I tried but had no luck. Below is my JSPDYNPAGE code...
    <%@ page import="javax.servlet.http.HttpServletResponse" %>
    <%@ page import="com.sapportals.portal.prt.component.IPortalComponentRequest,com.sapportals.portal.prt.component.IPortalComponentResponse"%>
    <HTML>
         <head>
         </head>
         <body>
    <%
    IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
    HttpServletResponse servletResponse = request.getServletResponse(true);esss
    servletResponse.setStatus(500);
    %>
              </body>
         </HTML>
    It is not working showing portal run time error

  • Jsp dyn page open form results in new window

    Hi everybody,
    I have a problem dispaying results in new window.
    My portal component is a dyn page that dispay several jsp pages based on a integer switch parameter checked in the
    doProcessBeforeOutput method.
    One page is a form with a button that call onSearch custom method inside my component; this method process the request,
    fill the bean and set the integer switch that doProcessBeforeOutput check then get the right jsp.
    All works fine but I want to display the onSearch method results in a new window.
    What I have to do?
    Thanks,
    Andrea

    Hi Andrea,
         I am also facing the same issue.
    Were you able to call the component method from the JavaScript code.
    I have to display the results in a new page.
    Will all the methods like doProcessBeforeOutput() be executed when we traverse after the search button is clicked ?
    Thanks in advance,
    Brian.
    Edited by: Brian Fernandes on Mar 30, 2010 12:34 PM

  • While Consuming a WebService in JSP Dyn Page - There is an Error

    Hi Friends,
    I have a web service created in ASP.NET web Service.
    And I have Consumed the Web Service using WSDL URL.
    I need to write a code to refer that class in the JSP DynPage
    I have created like this in DoIntialization
    MyServiceName obj=(MyServiceName) PortalRuntime.getRuntimeResources().getService(MyServiceName.KEY);
    int a = 10;
    int b = 20;
    obj.Add1(a,b);
    but it shows an error
    "The method Add1 Method(Add1 Method) is the type. MySErviceName is not Applicable for the arguements(int,int)"
    Please Help me in this regard.
    Thanks in Advance
    Thanks & Regards,
    Palani

    Hi Andy,
    I will let u know the sequence which i followed to consume the Webservice.
    NWDS --> File --> New --> Project --> Portal Application --> Create New Portal App Project.
    The Project is created.....
    After that i want to consume the Webservice for the same project...
    for that...
    NWDS --> File --> New --> Other --> Portal Application --> Create New Portal Application Object --> Selecting My Project?(intended prjct) --> Portal Webservice --> Portal Service from WSDL file - Client Side --> My WSDL URL --> Selecting the methods which i need to expose from the Webservice --> I gave unique name for my 1) Service 2) Alias 3) Package....and that was done....(other way is to add from portalapp.xml ??)
    After that i created a new JSPDyn page for my application in DoInitialization() method i tried to access the method from that webservice using the following code...
    MyServiceName obj=(MyServiceName) PortalRuntime.getRuntimeResources().getService(MyServiceName.KEY);
    I am successfully able to access the method from the webservice using the object which i have created but i am not able to pass arguments to that method...???
    I tried consuming same webservice created in .NET in .NET itself and i am able to pass arguments successfully.
    I tried to consume webservice created in ABAP in .NET and able to implement successfully...
    but the same ABAP webservice when  i tried to consume its not working with this NWDS.
    Is there any thing else i need to follow while consuming a webservice in the EP Perspectice of NWDS ???
    Deployable Proxy is required for that ?? if required how to create and use that ??
    Thanks in Advance,
    Palani

  • Reading R3 table in JSP Dyn Page...URGENT

    Hi All,
    I have created an JSP Dynpage Application after reading this thread:
    <a href="https://www.sdn.sap.com/irj/sdn/thread?messageID=3417619#3417619">https://www.sdn.sap.com/irj/sdn/thread?messageID=3417619#3417619</a>
    <b>My PortalApp.xml file is:</b>
    <?xml version="1.0" encoding="utf-8"?>
    <application>
      <application-config>
        <property name="PrivateSharingReference" value="com.sap.portal.htmlb"/>
      </application-config>
      <components>
        <component name="InteractiveList">
          <component-config>
            <property name="ClassName" value="com.abb.InteractiveList"/>
            <property name="ComponentType" value="jspnative"/>
            <property name="JSP" value="pagelet/InteractiveList.jsp"/>
          </component-config>
          <component-profile>
                <property name="tagLib" value="/SERVICE/htmlb/taglib/htmlb.tld"/>
          </component-profile>
        </component>
      </components>
      <services/>
    </application>
    My InteractiveList.java file contains:
    package com.amit;
    import java.util.Vector;
    import com.sap.engine.lib.xml.signature.Data;
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.JCO;
    import com.sapportals.htmlb.page.DynPage;
    import com.sapportals.htmlb.page.PageException;
    import com.sapportals.htmlb.table.DefaultTableViewModel;
    import com.sapportals.portal.htmlb.page.JSPDynPage;
    import com.sapportals.portal.htmlb.page.PageProcessorComponent;
    import com.sapportals.portal.prt.component.IPortalComponentProfile;
    import com.sapportals.portal.prt.component.IPortalComponentRequest;
    public class InteractiveList extends PageProcessorComponent {
      public DynPage getPage(){
        return new InteractiveListDynPage();
      public static class InteractiveListDynPage extends JSPDynPage{
        private DataBean DataBean = null;
        public void doInitialization(){
          IPortalComponentProfile profile = ((IPortalComponentRequest)getRequest()).getComponentContext().getProfile();
          Object o = profile.getValue("DataBean");
          if(o==null || !(o instanceof DataBean)){
               System.out.println("In the IF ");
            DataBean = new DataBean();
            profile.putValue("DataBean",DataBean);
          } else {
              DataBean = (DataBean) o;
           String name = "Amit ";
           DataBean.setname(name);
          // fill your bean with data here...
           //InteractiveList interactive_list = new InteractiveList();     
        public void doProcessAfterInput() throws PageException {
        public void doProcessBeforeOutput() throws PageException {
          this.setJspName("InteractiveList.jsp");
      public DefaultTableViewModel getData(String USER, String PWD,String R3ip) {
                     com.sap.mw.jco.IRepository repository;
                     JCO.Pool pool = JCO.getClientPoolManager().getPool("R3");
                     if (pool == null) {
                          //JCO.removeClientPool("R3");
                          JCO.addClientPool(
                               "R3",
                               10,
                               "120",
                               USER,
                               PWD,
                               "EN",
                               "138.223.4.106",
                               "00");
                     repository = JCO.createRepository("TTL", "R3");
                     JCO.Client client = null;
                     //               Get a function template from the repository
                     IFunctionTemplate ftemplate =
                          repository.getFunctionTemplate("BAPI_SALESORDER_GETSTATUS");
                     //           Create a function from the template
                     JCO.Function function = ftemplate.getFunction();
                                    client = JCO.getClient("R3");
                                    JCO.ParameterList input = function.getImportParameterList();
                     input.setValue("0053100700", "SALESDOCUMENT");
                                    client.execute(function);
                     JCO.Table sales_orders =
                          function.getTableParameterList().getTable("STATUSINFO");
                     Vector row = new Vector();
                     Vector tbl = new Vector();
                     Vector colNames = new Vector();
                     //     Loop over all rows
                     do {
                          //     Loop over all columns in the current row
                          for (JCO.FieldIterator e = sales_orders.fields();
                               e.hasMoreElements();
                               JCO.Field field = e.nextField();
                               row.add(field.getString());
                               //System.out.println(field.getName() + ":\t" + field.getString());
                          } //for
                          tbl.add(row);
                     } while (sales_orders.nextRow());
                     sales_orders = null;
                     sales_orders =
                          function.getTableParameterList().getTable("STATUSINFO");
                     sales_orders.nextRow();
                     for (JCO.FieldIterator e = sales_orders.fields();
                          e.hasMoreElements();
                          JCO.Field field = e.nextField();
                          colNames.add(field.getName().toString());
                     DefaultTableViewModel dtvModel =
                          new DefaultTableViewModel(tbl, colNames);
                     JCO.releaseClient(client);
                     return dtvModel;
    And my Bean Class contains following code:
    package com.amit;
    import java.io.Serializable;
    import com.sapportals.htmlb.table.DefaultTableViewModel;
    public class DataBean implements Serializable {
         public DefaultTableViewModel model;
         public String name;
         public DefaultTableViewModel getModel() {
              System.out.println("Hi There ");
              return model;
         public void setModel(DefaultTableViewModel model) {
              this.model = model;
         public String getname(){
              return name;
         public void setname(String name){
              this.name = name;
    When I try  to Run the par file I am getting the Static Text in TextView but Text from myBean.getname() is not coming.
    Can you tell me the reason. Is there any problem in the code.
    Thanks in Advance,
    Amit
    Message was edited by:
            Amit

    Double post http://forum.java.sun.com/thread.jspa?threadID=647550&tstart=0

  • How to instantiate object in JSP/STRUTS page?

    I worked through the STRUTS tutorial (http://rzserv2.fhnon.de/~lg002556/struts/Doku.html) but I get errors when I try to instantiate an object of a class that is in my WEB-INF/classes directory:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 14 in the jsp file: /BookSerialize.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    D:\Programme\jakarta-tomcat-4.1.12\work\Standalone\localhost\strutsdemo\BookSerialize_jsp.java:86: cannot resolve symbol
    symbol : class Book
    location: class org.apache.jsp.BookSerialize_jsp
    Book book = new Book();
    ^
    The Book.class (and other classes) is in the WEB-INF/classes directory. The BookSerialize.jsp is here:
    <%@ page language="java" import="java.beans.XMLEncoder, java.beans.XMLDecoder, java.io.*"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
    <html:html locale="true">
    <head>
    <html:base/>
    <title><bean:message key="index.title"/></title>
    </head>
    <body bgcolor="white">
    <h2>Book Serialization</h2>
    <%
    Book book = new Book();
    book.setTitle("A great Book about Struts");
    book.setPages(100);
    out.println("<member>First Title: " + book.getTitle() + "</member>");
    try {
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(new FileOutputStream("/Sample.xml")));
    encoder.writeObject(book);
    encoder.close();
    } catch(Exception ex) {
    out.println(ex);
    book.setTitle("A great Book about Struts, Second Edition");
    out.println("<member>Second Title: " + book.getTitle() + "</member>");
    try {
    XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream("/Sample.xml")));
    book = (Book) decoder.readObject();
    decoder.close();
    } catch(Exception ex) {
    out.println("<h1>" + ex + "</h1>");
    out.println("<member>Third Title: " + book.getTitle() + "</member>");
    %>
    </body>
    </html:html>
    I also get the same error when deploying and (trying to) run on the J2EE 1.3.1 server.
    So far, I just used JSP pages working with beans (usebean tag). Is it possible at all to just do a
    MyClass myObject = new MyClass();
    within a JSP page, if MyClass.class is in the WEB-INF/classes of the web application?
    Is there any kind of import missing? Book.class is in the default package, so i can't state it in the page directive/import parameter of the JSP page...
    any advice?

    I think, I got it: you have to use package names for your classes and avoid the default package. After I used a package name, it was possible to instantiate the object ....

  • JSP Dyn Page want to display "Loading..." img + message

    Hi, we have EP6 SP2 environment. I have a JSPDynPage component that does a lot of preprocessing then loads the jsp page. Most of the time it spends in doProcessBeforeOutput() (has to connect to 2 backends and pull some data out). it is very slow loading. Can anybody tell me how we can show a nice loading image and a message WHILE the preprocessing is done? Thank you in advance.

    Well, was messing with it for a few hours last night since I got no replies - and that is what I did: I am writing out a <span><loading image> Loading...</span> in my doInitialization() function in Java (before it is doing all the backend connect). Then in a .jsp file I am hiding it with ...display ="none" call. It is a hack, but will do for now till I figure out how to display it sooner.
    After deploying this to our dev Portal (which is not slow, the prod is), I realized that most of the "loading" time it spends pregenerating "other" html that is dumped on the page before my code. So will try to figure out how to speed that up. Will keep you posted.

  • Sytax highlighiting for Jsp Dyn Pages for portal development.

    Hey,
    I am doing JSP with the htmlb taglib for portals. When I edit a jsp page in the Developer Studio, I expect syntax highlighting. This is what I see in the documentation for jsp editing as well - you know where the keywords are highlighted.
    Sytax highlighiting for jsp in Developer Studio for portal development.
    http://help.sap.com/saphelp_nw04s/helpdata/en/ce/e0a341354ca309e10000000a155106/content.htm
    OutputSuccess.jsp, OutputSuccessText.jsp are the two jsp's that are syntax highlighted on this page.
    In my Developer Studio this is not the case. Is a JSP editor and its highlighting not part of the Developer Studio. If it is, how do I get it to work.
    I also know that given the right taglib's, the editor also gives autocomplete for taglibs with its settings. I am hoping to speed up my development with this.
    Right now I am using a text editor for this. There are a couple of jsp plugin's such as Exadel or Lomboz which I can integrate if a jsp syntax editor is not there in the Developer Studio. I just wanted to know the right way to go about this.
    Thank you for your help.
    Sumit.

    Never mind. I was in the preview mode.

  • Pass parameters from JSP Dyn Page to WDJ Application

    Hi,
    I am trying to pass parameters from my JSPDyn Page to WDJ Application.
    I am using NWDS 7.1 EHP1
    My code is :
    function to_WEBDYNHK()
          EPCM.relaxDocumentDomain();
          EPCM.doNavigate
        ('ROLES://pcd:portal_content/Himanshu.Himanshu/TestDynUIApp?DynamicParameter="hkparam%3Dqwertyuio"');
    This method is being called on click of a button.
    hkparam is the parameter in question.
    The JSPDyn page is an iView and the WDJ application is a page and both have been assigned to a role.
    In the properties of the WDJ Page, I have removed DymanicParameter from "Do not Forward These Parameters To Web Dynpro" property.
    However I am getting null as the value of hkparam in my WDJ application.
    The code used is :
    IWDRequest request = WDProtocolAdapter.getProtocolAdapter().getRequestObject();
           String param1= request.getParameter("hkparam");
    What seems to be missing here.
    Please help.
    I went through the documentation on SDN but it does not seem to help.
    TIA,
    Himanshu

    Hi Himanshu,
    Try this code.
    EPCM.doNavigate("ROLES:portal_content/Himanshu.Himanshu/TestDynUIApp?hkparam=Dmypass1123")
    if the parameter is hkparam and the value to be passed is Dmypass1123. You need not change any design time property of the WD page, and WDProtocolAdapter should retrive the parameter.
    Regards,
    Vishweshwara P.K.M.

  • Modify MSS with version 60.1.18  ( JSP Dyn Page Concept)

    Hi All,
    We are working with MSS Business package.Our requirement is to display the custom fields data(infotype P0006) in Emergency contact details in the employee profile details.We were able to track the par file from the business package.
    It is com.sap.pct.hcm.eeprofileemergencycontact
    Also SAP has not given Source code to modify, can we use de compilers to get the code and modify it as per the requirement.
    What needs to be done by us to achieve this.
    It is using JCO to connect to SAP.
    It is calling the bapi HRWPC_RFC_ADDRESS_GETLIST.
    Now if we require those custom fields I think I need to copy the code of the SAP FM and need to change it.And also observed that Class names , data stucture names are hardcoded in the code.
    For example Hrwpc_S_AddressType is one of the class used.
    How is SAP creating these class files. What I guess there must be standard way to generate the required class files when I need to call a FM in SAP.
    Can any one let me know the way to achieve this requirement.
    Regards,
    ND.

    Hello Roy,
    Did you create two aliases for the R3 system named "SAP_R3_HumanResources" and "SAP_R3_Finanacials".
    Just confirm the names (case sensitive)
    Hope this helps..
    Pradeep

  • How can I get the "pageContext" object in jsp page?

    Hi everyone:
    I want to get struts's DataSource object in jsp page.So I should get the PageContext object in jsp page.My code is:
    ///////////////////datatest.jsp///////////////////////////////////
         DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    Is right?But I get the "NullPointerException" error in Tomcat.The connection pool in struts-config.xml is:
    <data-sources>
    <data-source key="mydatasource">
    <set-property property="autoCommit"
    value="false"/>
    <set-property property="description"
    value="MyWebSite Data Source Configuration"/>
    <set-property property="driverClass"
    value="org.gjt.mm.mysql.Driver"/>
    <set-property property="maxCount"
    value="4"/>
    <set-property property="minCount"
    value="2"/>
    <set-property property="password"
    value="qijiashe"/>
    <set-property property="url"
    value="jdbc:mysql://localhost:3306/myweb"/>
    <set-property property="user"
    value="lyo"/>
    </data-source>
    </data-sources>
    I can query the database in servlet.
    I think the method that I get the context is not right.Had someone get the pagecontext in jsp page?help :(

    Sorry I forgot that I had change the code:
    DataSource ds=(DataSource)pageContext.getAttribute(Action.DATA_SOURCE_KEY);
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    to the code:
    DataSource ds=(DataSource)pageContext.getAttribute("mydatasource");
         conn=ds.getConnection();
              stm=conn.createStatement();
              rs=stm.executeQuery(insertsql);
    mydatasource is the struts datasource in "struts-config.xml". I couldn't work

  • Calling a method in BPM Object from jsp page

    hi all,
    I try to call a method from BPM Object using <f:invokeUrl >
    I change server side method properties to yes.
    and then how can i get request and response object inside the BPM method.
    Thanks.

    Thanks for ur response,
    But i mention about BPM method inside BPM Object.
    i found this inside the documentation.
    methodName(Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response)
    i need to match above BPM method and <f:invokeUrl > tag. am i right?
    But i don't know how to create method with argument "Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response" inside BPM Object.
    I can't find any place to define method argument inside Oracle BPM studio.
    I don't know how to parse argument like "Fuego.Net.HttpRequest request, Fuego.Net.HttpResponse response"
    With Regards,
    Wai Phyo
    Edited by: user8729650 on Sep 9, 2009 7:03 PM
    Edited by: user8729650 on Sep 9, 2009 9:20 PM

  • Handle exception on server side and display a customized jsp error page

    Hi,
    I am developing a java/j2EE web application using servlet, jsp, ejb3 with JBOSS and ECLIPSE.
    Two cases can occur on the server side :
    1) either I have not an expected result in a method and in this case I want to display an error page (a JSP page I suppose) with a personnalized error message
    2) or I have an exception thrown and I want to display the exception message in the former JSP page
    I don't know how to cope with this problem of personnalized error message (or the message of a thrown exception) with a JSP page.
    Does anybody can help me ? Thank you
    Edited by: xflamant on Jun 20, 2009 10:51 AM

    For the case of an unknown Error, simply use a default error page.
    The redirection to this page can be accomplished by inserting folowing code into your web.xml:
         <error-page>
            <exception-type>java.lang.Throwable</exception-type>
            <location>/WEB-INF/jsp/error.jsp</location>       
        </error-page>Known exception can be caught via a try-catch block.
    Then simply dispatch to the page you want displayed an add an attribute containing the error message to the response object.
    This attribute can then be used in the target page to diplay the error.

Maybe you are looking for

  • System Restore to previous iTunes version caused "New iTunes Library" error

    So like others I upgraded to 11; tried to keep an open mind but the thing keeps hanging up on me, running slowly, and wow I hate not being able to see my playlists next to my library. Even little things like deleting a song from a playlist and iTunes

  • Cisco Unity ServerUpdatesWizard-v.3.0.02-12-2009

    Hi I've just applied the latest OS security updates, hot fixes and patches updates to our Unity 5 VM cluster and understand that the Server Updates Wizard is the best way to approach this. Following the update, I ran a cursory check against Microsoft

  • Resize a check box

    Hi, Does anyone know how to resize a check box in LabVIEW 7.1? Thanks, Paulo

  • Why am I unable to use Dashlane now?

    Firefox updated and no longer communicates with Dashlane.

  • SICF - Test Service

    Hi, In the SICF, during test service of SAP/XI/Engine, I am getting the following error: - <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">   <SOAP:Header /> - <SOAP:Body> - <SOAP:Fault xmlns:SOAP="http://schemas.xmlsoap.org/soa