IllegalStateException: strict servlet API: cannot call getWriter()

I am getting an exception in Weblogic when I am trying to display a pdf file in a web page.
java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
I am using the following code code
ByteArrayOutputStream baos;
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
I have seen this error in so many discussion forum and there is no proper solution for this error.
I am able to see the pdf page even with this exception. But I want to get rid of this exception also from Weblogic.

I just did a quick (and dirty!) test with the following to display a jpg image and it worked for me without any trace of an exception:
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)  throws ServletException, IOException {
        response.setContentType("image/jpg");
        File f = new File("/Users/me/Desktop/IMG_0032.JPG");
        byte[] bits = new byte[(int) f.length()];
        FileInputStream fos = new FileInputStream(f);
        fos.read(bits);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        baos.write(bits, 0, bits.length);
        baos.writeTo(response.getOutputStream());
        baos.close();
        fos.close();
    }Note that there is no call anywhere to response.getWriter() in that.
I'd guess the exception is directing you at what the problem is, at least as the server is seeing it -- somewhere in the execution of the request path there would appear to be call to response.getWriter() occurring after a call to response.getOutputStream() has been called, which is not permitted on WLS according to the error message.
Do you use filters on this app? If response.getWriter() has been called on the same response object in a post request filter phase, that would be on the same call path with the same response object and would result in the exception.
-steve-

Similar Messages

  • Strict servlet API: cannot call getWriter() after getOutputStream()

    Hi,
    Am getting below exception when i click on create report button.
    It was successfully running in development machine, when we deploy the same application into the testing server.
    what could be problem..
    am using JSF 2.0, Primefaces 3.5, Jdeveloper and Weblogic 12 C server..
    java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after getOutputStream()
      at weblogic.servlet.internal.ServletResponseImpl.getWriter(ServletResponseImpl.java:299)
      at org.apache.myfaces.application.jsp.JspViewHandlerImpl.renderView(JspViewHandlerImpl.java:362)
      at org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
      at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:140)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:155)

    Issue resolved, because testing machine doesn't have specified font in font directory.
    recompiled the jrxml file with arial font its working both the env machine..

  • Strict servlet API: cannot call getOutputStream() after getWriter()

    i have an applet which will communicate with a servet ,  but got following error in the servlet
    java.lang.IllegalStateException: strict servlet API: cannot call getOutputStream() after getWriter()
    at weblogic.servlet.internal.ServletResponseImpl.getOutputStream(ServletResponseImpl.java:280)
    at oracle.osl.lt.web.servlets.AudioServlet._processGetPlayList(AudioServlet.java:235)
    at oracle.osl.lt.web.servlets.AudioServlet.doPost(AudioServlet.java:91)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)
    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.wls.filter.SSOSessionSynchronizationFilter.doFilter(SSOSessionSynchronizationFilter.java:276)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:111)
    at java.security.AccessController.doPrivileged(Native Method)
    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)
    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)
    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)
    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)
    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3681)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)
    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)
    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    SUBSYSTEM = HTTP USERID = <WLS Kernel> SEVERITY = Error THREAD = [ACTIVE] ExecuteThread: '1' for queue: 'weblogic.kernel.Default (self-tuning)' MSGID = BEA-101020 MACHINE = p1dvosl02 TXID = CONTEXTID = TIMESTAMP = 1318836952580
    WatchAlarmType: AutomaticReset
    WatchAlarmResetPeriod: 30000
    >
    *below _processGetPlayList() is called by doPost() of the servlet.*
    seems the exception is thrown due to response.getOutputStream()?
    any idea? thanks!!
    private void _processGetPlayList(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    try {
    ObjectOutputStream objectOut =
    new ObjectOutputStream(new BufferedOutputStream(response.getOutputStream()));
    try {
    RichDataDTOExt richData = _getRichData(request);
    if (richData == null) {
    Log.web().debug(s7);
    throw new ServletException(s7);
    objectOut.writeObject(richData.getAudioRecordings().getAll(new ContentRefDTO[0]));
    finally {
    objectOut.close();
    catch (IOException e) {
    Log.web().error(e.getMessage());
    throw new ServletException();
    }

    thanks for you reply. but seems we don't call getWriter() at all in our code.
    actually this error only happen in our customer's env, no this issue in our development env.
    besides using getOutputStream() and getWriter() simultaneously for same response, is this maybe related with some web server configuration?

  • IllegalStateException: strict servlet API:

    Hello All,
    I'm trying to do a simple rpc webservice. The wsgen process runs to a successful
    completion and I deploy the result to Weblogic 6.1 sp1, which is also successful.
    When accessing this new service, everything runs fine until the response is generated
    and I get following stack trace:
    <br>
    java.lang.IllegalStateException: strict servlet API: cannot call getWriter() after
    getOutputStream() <br>
    at weblogic.servlet.internal.ServletResponseImpl.getWriter(ServletResponseImpl.java:160)
    <br>
    at weblogic.soap.server.servlet.StatelessBeanAdapter.reportFault(StatelessBeanAdapter.java:238)
    <br>
    etc...
    It would appear that this is being generated in a Weblogic class. There is no
    mention of my EJB in the stack trace.
    Has anyone seen this error? Or, better yet, what causes it and what is the solution?
    Thanks,
    Kris

    Kris,
    I too have run into this problem with Weblogic 6.1. The first time I
    got this exception was when I had java.util.Date attributes within my
    serializable data object that I was returning from my WebService interface.
    When those date attributes were set with values, I would get the exception
    outlined below. Then I set those date values to null, and everything worked
    fine.
    Coincidentally, I'm currently have the same problem with a serializable
    object that has another serializable object defined as an attribute. I'm
    not wondering if Weblogic can't handle Serializable objects within other
    Serializable objects?
    I guess my suggestion would be to look at the values you are returning
    and passing in as parameters to your WebService interface, are there any
    Serializable objects that have other Serializable objects defined as
    attributes ( Strings don't count )? If so, set them to null and try your
    WebService again. ( Does that make sense?? )
    Hope this helps?
    Jeff
    "Kris W. Keener" <[email protected]> wrote in message
    news:3bd71794$[email protected]..
    >
    Hello All,
    I'm trying to do a simple rpc webservice. The wsgen process runs to asuccessful
    completion and I deploy the result to Weblogic 6.1 sp1, which is alsosuccessful.
    When accessing this new service, everything runs fine until the responseis generated
    and I get following stack trace:
    <br>
    java.lang.IllegalStateException: strict servlet API: cannot callgetWriter() after
    getOutputStream() <br>
    atweblogic.servlet.internal.ServletResponseImpl.getWriter(ServletResponseImpl.
    java:160)
    <br>
    atweblogic.soap.server.servlet.StatelessBeanAdapter.reportFault(StatelessBeanA
    dapter.java:238)
    <br>
    etc...
    It would appear that this is being generated in a Weblogic class. There isno
    mention of my EJB in the stack trace.
    Has anyone seen this error? Or, better yet, what causes it and what is thesolution?
    >
    Thanks,
    Kris

  • IllegalStateException: getOutputStream() has already been called

    Hi guys,
    I am writing JSP to retrieve data from database and export to the user as csv or zip file. It has to be binary. I would like to a download dialog to show up and allow users to choose where to save the exported file.
    Funcitonally, it works fine althrough I get an error page saying nothing to display. But it always complains that IllegalStateException: getOutputStream() has already been called for this session. I have done much research and testing, but....in vain.
    Hope somebody could help me with this. so frustrated that I am about to explode.
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="application/octet-stream">
            <title>Load Page</title>
        </head>
        <body >
            <% OutputStream outRes = response.getOutputStream( ); %><%@page contentType="application/octet-stream"%><%
            %><%@page pageEncoding="UTF-8" import="java.sql.*,java.io.*,java.util.*,java.util.zip.*,java.math.BigDecimal;"%><%
            %><%
            try {
                Class.forName(ResourceBundle.getBundle("map").getString("driver"));
            } catch (ClassNotFoundException ex) {
               //ex.printStackTrace();
               return;
            String EXPORT_DIR = ResourceBundle.getBundle("map").getString("SUBMITTAL_EXPORT_DIR");
            String EXPORT_NAME = ResourceBundle.getBundle("map").getString("SUBMITTAL_NAME");
            String EXPORT_ZIP_NAME = ResourceBundle.getBundle("map").getString("SUBMITTAL_ZIP_NAME"); 
            String sqlQuery = "SELECT EMP_ID, EMP_NAME FROM EMP";
            Connection conn = null;
            Statement stmt = null;
            ResultSet rs = null;
            OutputStream expStream = null;
            boolean success = false;
            try {
                //out.println("<p>Connecting to the source database ...");
                // establish database connection
                conn = DriverManager.getConnection(
                        ResourceBundle.getBundle("map").getString("sqlurl"),
                        ResourceBundle.getBundle("map").getString("ORACLE_DBUSER"),
                        ResourceBundle.getBundle("map").getString("ORACLE_DBPASSWORD") );
                stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
                rs = stmt.executeQuery(sqlQuery);
                //out.println("Done</p>");
                // open a file to write
                File exportFile = new File(EXPORT_DIR + File.separatorChar + EXPORT_NAME);
                if (exportFile.exists())  exportFile.delete();
                exportFile.createNewFile();
                expStream = new BufferedOutputStream(new FileOutputStream(exportFile));
                // iterate all records to save them to the file
                //out.print("<p>Exporting the table data ...");
                while(rs.next()) {
                    String recordString = "";
                    ResultSetMetaData metaData = rs.getMetaData() ;
                    int colCount = metaData.getColumnCount();
                    for(int i=1; i<=colCount; i++) {
                        int colType = metaData.getColumnType(i);
                        switch(colType) {
                            case Types.CHAR: {
                                String sValue = rs.getString(i);
                                if (rs.wasNull())
                                    recordString += ("'',");
                                else
                                    recordString += ("'"+ sValue + "',");
                                break;
                            case Types.VARCHAR: {
                                String sValue = rs.getString(i);
                                if (rs.wasNull())
                                    recordString += ("'',");
                                else
                                    recordString += ("'"+ sValue + "',");
                                break;
                            case Types.FLOAT: {
                                float fValue = rs.getFloat(i);
                                if (rs.wasNull())
                                    recordString += (",");
                                else
                                    recordString += (fValue + ",");
                                break;
                            case Types.DOUBLE: {
                                double dbValue = rs.getDouble(i);
                                if (rs.wasNull())
                                    recordString += (",");
                                else
                                    recordString += (dbValue + ",");
                                break;
                            case Types.INTEGER: {
                                int iValue = rs.getInt(i);
                                if (rs.wasNull())
                                    recordString += (",");
                                else
                                    recordString += (iValue + ",");
                                break;
                            case Types.NUMERIC: {
                                BigDecimal bdValue = rs.getBigDecimal(i);
                                if (rs.wasNull())
                                    recordString += (",");
                                else
                                    recordString += (bdValue + ",");
                                break;
                            default:
                                out.println("<p><font color=#ff0000> Unidentified Column Type "
                                        + metaData.getColumnTypeName(i) + "</font></p>"); */
                                success = false;
                                return;
                    recordString = recordString.substring(0, recordString.length()-1);
                    expStream.write(recordString.getBytes());
                    expStream.write((new String("\n")).getBytes());
                expStream.flush();
                //out.println("Done</p>");
                //out.println("<p>Data have been exported to " + filepath + "</p>");
                success = true;
            } catch (SQLException ex) {
               //out.println(ex.getStackTrace());
            } catch (IOException ex) {
               //out.println(ex.getStackTrace());
            } finally {
                if (expStream != null) {
                    try {
                        expStream.close();
                    } catch (IOException ex) {
                       // out.println(ex.getStackTrace());
                if (rs != null) {
                    try {
                        rs.close();
                    } catch(SQLException ex) {
                        //out.println(ex.getStackTrace());
                if (stmt != null) {
                    try {
                        stmt.close();
                    } catch(SQLException ex) {
                       // out.println(ex.getStackTrace());
                if(conn != null) {
                    try {
                        conn.close();
                    } catch(SQLException ex) {
                       // out.println(ex.getStackTrace());
            if (!success) return;
             * compress the exported CSV file if necessary
            int DATA_BLOCK_SIZE = 1024;
            if (request.getParameter("zip")!=null && request.getParameter("zip").equalsIgnoreCase("true")) {
                success = false;
                BufferedInputStream sourceStream = null;
                ZipOutputStream targetStream = null;
                try {
                    File zipFile = new File(EXPORT_DIR + File.separatorChar + EXPORT_ZIP_NAME);
                    if (zipFile.exists())  zipFile.delete();
                    zipFile.createNewFile();
                    FileOutputStream fos = new FileOutputStream ( zipFile );
                    targetStream = new ZipOutputStream ( fos );
                    targetStream.setMethod ( ZipOutputStream.DEFLATED );
                    targetStream.setLevel ( 9 );
                     * Now that the target zip output stream is created, open the source data file.
                    FileInputStream fis = new FileInputStream ( EXPORT_DIR + File.separatorChar + EXPORT_NAME );
                    sourceStream = new BufferedInputStream ( fis );
                    /* Need to create a zip entry for each data file that is read. */
                    ZipEntry theEntry = new ZipEntry ( EXPORT_DIR + File.separatorChar + EXPORT_NAME );
                     * Before writing information to the zip output stream, put the zip entry object
                    targetStream.putNextEntry ( theEntry );
                    /* Add comment to zip archive. */
                    //targetStream.setComment( "comment" );
                    /* Read the source file and write the data. */
                    byte[] buf = new byte[DATA_BLOCK_SIZE];
                    int len;
                    while ( ( len = sourceStream.read ( buf, 0, DATA_BLOCK_SIZE ) ) >= 0 ) {
                        targetStream.write ( buf, 0, len );
                     * The ZipEntry object is updated with the compressed file size,
                     * uncompressed file size and other file related information when closed.
                    targetStream.closeEntry ();
                    targetStream.flush ();
                    success = true;
                } catch ( FileNotFoundException e ) {
                    //e.printStackTrace ();
                } catch ( IOException e ) {
                    //e.printStackTrace ();
                } finally {
                    try {
                        if (sourceStream != null)
                            sourceStream.close ();
                        if (targetStream != null)
                            targetStream.close ();
                    } catch(IOException ex) {
                        //ex.printStackTrace();
                if (!success) return;
             * prompt the user to download the file
            //response.setContentType("text/plain");
            //response.setContentType( "application/octet-stream" );
            InputStream inStream = null;
            //OutputStream outRes = null;
            try {
                if (request.getParameter("zip")!=null && request.getParameter("zip").equalsIgnoreCase("true")) {
                    response.setHeader("Content-Disposition", "attachment;filename=" + EXPORT_ZIP_NAME);
                    inStream = new BufferedInputStream(new FileInputStream(EXPORT_DIR + File.separatorChar + EXPORT_ZIP_NAME));
                else {
                    response.setHeader("Content-Disposition", "attachment;filename=" + EXPORT_NAME);
                    inStream = new BufferedInputStream(new FileInputStream(EXPORT_DIR + File.separatorChar + EXPORT_NAME));
                out.clearBuffer();
                //outRes = response.getOutputStream(  );
                byte[] buf = new byte[4 * DATA_BLOCK_SIZE];  // 4K buffer
                int bytesRead;
                while ((bytesRead = inStream.read(buf)) != -1) {
                    outRes.write(buf, 0, bytesRead);
                outRes.flush();
                int byteBuf;
                while ( (byteBuf = inStream.read()) != -1 ) {
                    out.write(byteBuf);
                out.flush();
            } catch (IOException ex) {
                //ex.printStackTrace();
            finally {
                try {
                    if (inStream != null)
                        inStream.close();
                    if (outRes != null)
                        outRes.close();
                } catch(IOException ex) {
                    //ex.printStackTrace();
          %>
        </body>
    </html>

    So I went to the API: http://java.sun.com/j2ee/1.4/docs/api/
    Looked up ServletResponse, then looked for the getOutputStream() method. It says:
    "Throws:
    IllegalStateException - if the getWriter method has been called on this response"
    You can call only one of the getWriter or getOutputStream methods, not both. You are calling both. When you use a JSP, a variable called 'out' is generated (a PrintWriter) from the the Writer you get when response.getWriter() is called. This is done before your code gets executed as one of the functions that occur when a JSP is translated to a Servlet. You then write to that out variable when you print the HTML in the JSP code.
    This is best done in a Servlet, not a JSP, since there is no display and you require control over the servlet response.

  • I need to install servlet-api.jar in the libext folder.

    Hi I am doing a tutorial on struts 2.0.11.
    i need to install servlet-api.jar in the libext folder which I have created inside WEB-INF
    Now I have downloaded servlet.api which is in the zip form.
    When I extract the files. Its giving me two folders
    1. javax
    2. META-INF
    Inside javax there is a folder called servlet. Inside servlet folder there are
    a) bunch of call files
    b) http folder
    c) resources folder
    Inside http folder there are
    a) class files
    b) properties files
    Inside the resources folder there are
    a) dtd files
    b) xsd files
    Inside the META-INF folder there is the manifest.mf file
    I just need servlet-api.jar
    I think that I have extracted the contents of servlet-api.jar by using the extract feature of winzip.
    Do you think that by just changing the extension of the file from servlet-api.zip to servlet-api.jar it will do the trick or do i need to do something else.
    Please guide

    pksingh79 wrote:
    Hi ^^,
    your replies were very helpful. I did try to check the lib folder of the webserver and there was not servlet-api.jar. However I downloaded a dummy project and it did have servlet-api.jar in it, so I am ok for now.
    thanks and regards,
    PrashantYou should not be doing that. Always use the one from the application server which you're going to use. Otherwise you will possibly get in runtime trouble due to version differences.
    The actual location and filename of the servlet API might differ per application server implementation. If it was for example Tomcat 6, it is the servlet-api.jar in the /lib directory. If it was for example Glassfish (the current release), then it is the javaee.jar in the /lib directory.

  • Javax.servlet.ServletException: Cannot create bean of class

    People,
    HELP!! I am getting desperate!!!
    I am a newbie when it comes to TOMCAT, but i have been using Blazix before.
    My current system is using APACHE/TOMCAT on a Solaris machine and I keep hitting the same problem. I have gone through the archives but the only thing it states is to check the directory which i have done.
    I keep getting:
    Error 500
    Internal Error
    javax.servlet.ServletException: Cannot create bean of class MyClass
    The code used to work on the Blazix server so i am assuming it is something to do with a config parameter somewhere - but i do not know where. I have checked the directory/package structure and they seem to work. It even serves it when they are html pages not jsp, but obviously wont use the bean. :(
    I can post code if necessary.
    Please help
    Steve

    The FormData.class file is in examples/WEB-INF/classes/ directory.
    Is this wrong? then should it be in a package called examples.steve???
    <TITLE> Poc </TITLE>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <META NAME="Generator" CONTENT="Mozilla/4.61 [en] (WinNT; I) [Netscape]">
    <META NAME="Author" CONTENT="Steve Brodie">
    <META NAME="Proof of Concept order entry system" CONTENT="">
    <META NAME="PROOF OF CONCEPT ORDER ENTRY SYSTEM " CONTENT="">
    </HEAD>
    <%@ page import="steve.FormData" %>
    <jsp:useBean id="user" class="steve.FormData"/>
    <jsp:setProperty name="user" property="*"/>
    <FORM METHOD=POST ACTION="SaveDetails.jsp">
    <CENTER>
    <H1>     
    POC CNS demo <BR>
    POC Order Entry System <BR></H1>
    <H2><CENTER>PROOF OF CONCEPT ORDER ENTRY SYSTEM <BR>
    in order to illustrate the use of an new product<BR></H1>
    </CENTER>
    <BODY>
    Please enter the following details: <BR>
    Second name <INPUT TYPE=TEXT NAME=secondName SIZE=20><BR>
    First name <INPUT TYPE=TEXT NAME=firstName SIZE=20><BR>
    Address <INPUT TYPE=TEXT NAME=address1 SIZE=20><BR>
    Address <INPUT TYPE=TEXT NAME=address2 SIZE=20><BR>
    Post Code <INPUT TYPE=TEXT NAME=postCode SIZE=10><BR>
    Phone NO. <INPUT TYPE=TEXT NAME=phone SIZE=10><BR>
    <BR>
    Credit Card<INPUT TYPE=TEXT NAME=credit SIZE=15><BR>
    <BR>
    Quality of Service:
    <SELECT TYPE=TEXT NAME="QoS">
    <OPTION SELECTED TYPE=TEXT NAME=Gold>Gold <BR>
    <OPTION TYPE=TEXT NAME=Silver>Silver <BR>
    <OPTION TYPE=TEXT NAME=Bronze>Bronze <BR>
    </SELECT>
    <BR>
    <BR>
    <INPUT TYPE=RESET>
    <P><INPUT TYPE=SUBMIT>
    <BR>
    <BR>
    <IMG SRC=../images/Cisco.gif>
    </FORM>
    </BODY>
    </HTML>
    package steve;
    * @author Steven Brodie
    * @date
    * @version 0.0
    import java.io.*;
    import java.lang.*;
    import java.util.*;
    public class FormData {
         String secondName = null;
         String firstName = null;
         String address1 = null;
         String address2 = null;
         String postCode = null;
         int credit = 0;
         int phone = 0;
         String qos = null;
         String file = "out";
         String filex = "xout";
         PrintWriter pout = null;
         PrintWriter xout = null;
         FormData() {
              try {
                   pout = new PrintWriter(new BufferedWriter(new FileWriter(file + ".txt")));
                   xout = new PrintWriter(new BufferedWriter(new FileWriter(filex + ".xml")));
              xout.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
              xout.println("<OrderEntry xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
              xout.println("xsi:noNamespaceSchemaLocation=\"http://machine2.com:8080/xml/xsd/OrderEntry.xsd\">");
              } catch (IOException ioe) {
                   System.err.println("DataFileWriter error ioe on init");
                   ioe.printStackTrace();
                   System.exit(1);
    public void setFirstName( String value ) {
    firstName = value;
              System.out.println(firstName);
              pout.println(firstName);
              xout.println("<firstname value= \"" + firstName + "\"/>");
    public void setSecondName( String value ) {
    secondName = value;
              System.out.println(secondName);
              pout.println(secondName);
              xout.println("<secondname value= \"" + secondName + "\"/>");
    public void setAddress1( String value ) {
    address1 = value;
              System.out.println(address1);
         pout.println(address1);
              xout.println("<address1 value= \"" + address1 + "\"/>");
    public void setAddress2( String value ) {
    address2 = value;
              System.out.println(address2);
              pout.println(address2);
              xout.println("<address2 value= \"" + address2 + "\"/>");
    public void setPostCode( String value ) {
    postCode = value;
              System.out.println(postCode);
              pout.println(postCode);
              xout.println("<postCode value= \"" + postCode + "\"/>");
    public void setCredit( int value ) {
    credit = value;
              System.out.println(credit);
              pout.println(credit);
              xout.println("<creditCard value= \"" + credit + "\"/>");
         public void setPhone( int value) {
              phone = value;
              System.out.println("0" + phone);
              pout.println("0" + phone);
              xout.println("<phoneNo value= \"0" + phone + "\"/>");
    public void setQoS( String value ) {
    qos = value;
              System.out.println(qos);
              pout.println(qos);
              xout.println("<QoS value= \"" + qos + "\"/>");
              xout.println("</OrderEntry>");
              pout.flush();
              pout.close();
              xout.flush();
              xout.close();
    public String getFirstName() {
              return firstName;
    public String getSecondName() {
              return secondName;
    public String getAddress1() {
              return address1;
    public String getAddress2() {
              return address2;
    public String getPostCode() {
              return postCode;
    public int getCredit() {
              return credit;
         public int getPhone() {
              return phone;
         public String getQoS() {
              return qos;

  • Logging Error Message in Console  [Servlet Error]-[Cannot find FacesContex]

    Hi,
    I am using Web Application with JSF . but when i log in into the web appl everthing is fine but in back end i mean the console of RAD Tool having some logging Error message:
    SRVE0026E: [Servlet Error]-[Cannot find FacesContext]: javax.servlet.jsp.JspException: Cannot find FacesContext
    at javax.faces.webapp.UIComponentTag.doStartTag(UIComponentTag.java(Compiled Code))
    at com.sun.faces.taglib.jsf_core.ViewTag.doStartTag(ViewTag.java(Compiled Code))
    at org.apache.jsp._index._jspService(_index.java:86)
    at com.ibm.ws.webcontainer.jsp.runtime.HttpJspBase.service(HttpJspBase.java(Compiled Code))
    at javax.servlet.http.HttpServlet.service(HttpServlet.java(Compiled Code))
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet$JspServletWrapper.service(JspServlet.java(Compiled Code))
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.serviceJspFile(JspServlet.java(Compiled Code))
    at com.ibm.ws.webcontainer.jsp.servlet.JspServlet.service(JspServlet.java(Compiled Code))
    So could you please help me find out the solution for this :
    While i am using the code in jsp page:
    <%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@taglib uri="http://www.ibm.com/jsf/html_extended" prefix="hx"%>
    <%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <HTML>
    <HEAD>
    <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <META http-equiv="Content-Style-Type" content="text/css">
    <TITLE>Web App
         <f:view>
              <h:outputText value="#{dataInfo.info}"/>
         </f:view>
    </TITLE>
    Suggest me the solution:
    Regards,
    Prabhat

    This usually means that you call the JSF page the wrong way. Try something like http://hostname:port/servletcontextroot/faces/page.jspx
    --olaf                                                                                                                                                                                                                                                                                                   

  • Javax.servlet.ServletException: Cannot find bean CustForm in any scope

    while i m running my struts application.. i m getting this error.. can any one pointout wat error is this...
    javax.servlet.ServletException: Cannot find bean CustForm in any scope
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:533)
         at org.apache.jsp.Result_jsp._jspService(Result_jsp.java:100)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
         at org.apache.struts.action.RequestProcessor.processForwardConfig(RequestProcessor.java:455)
         at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:279)
         at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
         at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke(JBossSecurityMgrRealm.java:220)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke(ContainerStatsValve.java:76)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2417)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:65)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:197)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:781)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:549)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:605)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:677)
         at java.lang.Thread.run(Thread.java:534)

    hi shanu
    getting in jsp call..
    ERROR [Engine] ApplicationDispatcher[customTag] Servlet.service() for servlet jsp threw exception.
    n this is the action
    <action-mappings >
         <action path="/select" type="customTld.CustAction" name="custform" scope="request">
              <forward name="ok" path="/Result.jsp"/>
         </action>
         </action-mappings >

  • ESB: Cannot call setRollbackOnly()

    Hi,
    can anybody explain, what i have to do, if there is an error message:
    Cannot call setRollbackOnly() current thread is NOT associated with a transaction
    and the ESB has the following trace?
    oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: Eine unbehandelte Exception wurde im ESB-System ausgelöst. Es wurde folgende Exception gemeldet: "oracle.tip.esb.server.common.exceptions.BusinessEventRetriableException: Eine unbehandelte Exception wurde im ESB-System ausgelöst. Es wurde folgende Exception gemeldet: "org.collaxa.thirdparty.apache.wsif.WSIFException: exception on JaxRpc invoke: start fault message: java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction :end fault message at com.collaxa.cube.ws.wsif.providers.oc4j.jaxrpc.WSIFOperation_JaxRpc.invokeOperation(WSIFOperation_JaxRpc.java:1714) at com.collaxa.cube.ws.wsif.providers.oc4j.jaxrpc.WSIFOperation_JaxRpc.invokeRequestResponseOperation(WSIFOperation_JaxRpc.java:1460) at com.collaxa.cube.ws.wsif.providers.oc4j.jaxrpc.WSIFOperation_JaxRpc.executeRequestResponseOperation(WSIFOperation_JaxRpc.java:1182) at oracle.tip.esb.server.common.wsif.WSIFInvoker.executeOperation(Unknown Source) at oracle.tip.esb.server.common.wsif.WSIFInvoker.nextService(Unknown Source) at oracle.tip.esb.server.common.wsif.WSIFInvoker.nextService(Unknown Source) at oracle.tip.esb.server.service.impl.outadapter.OutboundAdapterService.nextService(Unknown Source) at oracle.tip.esb.server.service.impl.outadapter.OutboundAdapterService.processBusinessEvent(Unknown Source) at oracle.tip.esb.server.dispatch.InitialEventDispatcher.dispatchNonRoutingService(Unknown Source) at oracle.tip.esb.server.dispatch.InitialEventDispatcher.dispatch(Unknown Source) at oracle.tip.esb.server.dispatch.BusinessEvent.raise(Unknown Source) at oracle.tip.esb.utils.EventUtils.raiseBusinessEvent(Unknown Source) at oracle.tip.esb.server.service.EsbRouterSubscription.onBusinessEvent(Unknown Source) at oracle.tip.esb.server.dispatch.EventDispatcher.executeSubscription(Unknown Source) at oracle.tip.esb.server.dispatch.InitialEventDispatcher.processSubscription(Unknown Source) at oracle.tip.esb.server.dispatch.InitialEventDispatcher.processSubscriptions(Unknown Source) at oracle.tip.esb.server.dispatch.EventDispatcher.dispatchRoutingService(Unknown Source) at oracle.tip.esb.server.dispatch.InitialEventDispatcher.dispatch(Unknown Source) at oracle.tip.esb.server.dispatch.BusinessEvent.raise(Unknown Source) at oracle.tip.esb.wsif.WSIFOperation_ESB.executeRequestResponseOperation(Unknown Source) at com.collaxa.cube.ws.WSIFInvocationHandler.invoke(WSIFInvocationHandler.java:431) at com.collaxa.cube.ws.WSInvocationManager.invoke2(WSInvocationManager.java:416) at com.collaxa.cube.ws.WSInvocationManager.invoke(WSInvocationManager.java:222) at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__invoke(BPELInvokeWMP.java:736) at com.collaxa.cube.engine.ext.wmp.BPELInvokeWMP.__executeStatements(BPELInvokeWMP.java:371) at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:195) at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3271) at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1697) at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75) at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:184) at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:269) at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5244) at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1083) at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.createAndInvoke(CubeEngineBean.java:132) at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.syncCreateAndInvoke(CubeEngineBean.java:161) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.r
    This happens, when i call over ESB a BPEL which fails and a exception is thrown. But it occurs only every second invoke....

    Hi Dave,
    after some tests i get the feeling, that this problem is caused in the BPELConsole.
    1. I start a BPEL1 with wait for 2 min from BPELConsole. after 2 min i get:
    <Faulthttp://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>env:Server</faultcode>
    <faultstring>java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction</faultstring>
    </Fault>
    But in the audit trail i see the "right" output at the end.
    2. I start a BPEL2 which invokes the 2min wait (BPEL1). after 2 min i get:
    <Fault http://schemas.xmlsoap.org/soap/envelope/>
    <faultcode>env:Server</faultcode>
    <faultstring>java.lang.IllegalStateException: Cannot call setRollbackOnly() current thread is NOT associated with a transaction</faultstring>
    </Fault>
    But in the audit trail for the BPEL2 i can see the "right output at the end and the right response from BPEL1.
    Conclusion:
    BPEL1 does not get a timeout, because if this is the case, BPEL2 should never see the response of BPEL1.
    => the BPELConsole is the one with the problem.....?!
    UPDATE
    The conclusion was wrong. I tested the BPEL with a java proxy and got the same error ;-(
    Message was edited by:
    HEWizard

  • Javax.servlet.ServletContext cannot be resolved in Tomcat 5.5.12

    I deployed my web application in Tomcat 5.5.12 (Solaris 10 platform), and found following error message:
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    An error occurred at line: 16 in the jsp file: /countrydetail.jsp
    Generated servlet error:
    javax.servlet.ServletContext cannot be resolved
    An error occurred at line: 16 in the jsp file: /countrydetail.jsp
    Generated servlet error:
    ctx cannot be resolved
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:409)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
         com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
         com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
         com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:87)
         com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
         com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:117)
         javax.faces.webapp.FacesServlet.service(FacesServlet.java:198)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.
    Apache Tomcat/5.5.12
    The application was developed by NetBeans 5 RC2 and runed well under Windows platform.
    The error appears when I click link . At first I thought it may be caused by JSF, but I tested the sample JSF web with simliar link, and there is no problem.
    I do saw servlet-api.jar (which contains javax.servlet.ServeletContext) in Tomcat common/lib. Why tomcat can not locate the class?

    I solved this problem by deploying the application in Tomcat 5.5.15. It seems that the problem in above post is a bug in Tomcat 5.5.12.
    Details please refer to http://issues.apache.org/bugzilla/show_bug.cgi?id=38211

  • Javax.servlet.ServletContext cannot be resolved in Eclipse

    I am loading my project in Eclipse, I am getting this error :
    The type[b] javax.servlet.ServletContext cannot be resolved. It is indirectly referenced from required .class files
    I have set all the libraries, how can make eclipse avaliable with this class

    Which libraries have you set?
    javax.servlet.ServletContext would be in the J2EE servlet API.
    In tomcat this is [TOMCAT]/common/lib/servlet-api.jar
    In other containers it might be j2ee.jar

  • SMDIAG_WIZARD: "Cannot call application [filesystem] on agent [sap"

    Hello,
    I'm trying to transfer a landscape to Solution Manager Diagnostics with transaction SMDIAG_WIZARD. When i insert the installation path of the agent (in this case /usr/sap/SMD/J98) the wizard answer to me: "the specified path in not correct (see long text)" and the long text is "Cannot call application [filesystem] on agent [sap".
    If i enter in http://xxxx.xx.xx:50000/smd i can see the agent of the satellite system running. I don't know which can be the problem. If any knows i will be very grateful.
    Best regards.
    Carlos

    Hi Paula,
    thanks for your aswer, i have noticed that the solutions are in SMD, but when i mark the solution and pick on next appears this message:
    "The contents of at least one solution could not be retrieved from Solution Manager, or could not be uploaded to Diagnostics DB"
    [sapprd3.mma.es]->[sapdev1] : java.lang.IllegalStateException: Warnings occured during Initial Upload : XML Template parsing generated warnings
    Thu Jul 12 17:06:33 CEST 2007 | storeHost(...):Host [][sapdev1][10.31.10.100][null]:Cannot insert/update the host '[IHost: key=118425279[...] (RC=2)
    [sapprd3.mma.es]->[sapdev3] : java.lang.IllegalStateException: Warnings occured during Initial Upload : XML Template parsing generated warnings
    Thu Jul 12 17:06:33 CEST 2007 | storeHost(...):Host [][sapdev3][10.31.10.153][null]:Cannot insert/update the host '[IHost: key=118425279[...] (RC=2)
    Do you still want to proceed to next step ?
    If i ignore these warnings appears a system with ID ??? and status ?   and i can't continue.
    Do you know the reason?
    Thank you very much in advance, regards
    Carlos

  • Once i set classpath to servlet-api.jar, it doesnt Instantiate DbBean.

    I am using notepad editor. I am trying to instantiate a DbBean class inside the servlet's init() method.
    once i set (C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar) this path to compile the Controller servlet.
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>javac Controller.java
    Controller.java:5: package bean does not exist
    import bean.DbBean;
    ^
    Controller.java:14: cannot find symbol
    symbol : class DbBean
    location: class Controller
    DbBean dbbean = new DbBean();
    ^
    Controller.java:14: cannot find symbol
    symbol : class DbBean
    location: class Controller
    DbBean dbbean = new DbBean();
    ^
    3 errors
    C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\ROOT\WEB-INF\classes>
    this is my servlet
    import java.sql.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import bean.DbBean;
    public class Controller extends HttpServlet
    public void init(ServletConfig config)throws ServletException
    ServletContext context = config.getServletContext();
    context.setAttribute("base_url",config.getInitParameter("base_url"));
    {color:#ff0000}DbBean dbbean = new DbBean();{color} {color:#0000ff}error showing in this line
    {color}dbbean.setDburl(config.getInitParameter("dburl"));
    dbbean.setUserName(config.getInitParameter("username"));
    dbbean.setPassward(config.getInitParameter("pwd"));
    /// database bean can be access from jsp page
    context.setAttribute("dbbean",dbbean);
    /// Load the data base driver
    try{
    Class.forName(config.getInitParameter("jdbcDriver"));
    catch(ClassNotFoundException e)
    System.out.println(e.toString());
    super.init(config);
    public void doGet(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    doPost(req,res);
    public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException
    String base = "/onlinetest1/";
    String url = base + "login.jsp";
    String action = req.getParameter("action");
    if(action!=null)
    if(action.equals("successlogin.jsp"));
    url = base + "successlogin.jsp";
    RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(url);
    dispatcher.forward(req,res);
    public void destroy()
    System.out.println("Servlet stopped");
    This below class can be put inside bean folder( (ie)sub dir of controller servlet)
    package bean;
    import java.sql.*;
    import java.util.*;
    import java.io.*;
    public class DbBean
    String dburl="";
    String dbuser="";
    String dbpass="";
    public void setDburl(String url)
    dburl = url;
    public void setUserName(String uname)
    dbuser = uname;
    public void setPassward(String pwd)
    dbpass = pwd;
    What to do to rectify this, please help me why this error coming,

    hi,
    Actually i did my ordinary package compilation example below, its run correctly, but after set classpath to %tomcat-home%\common\lib\servlet-api.jar(for same programs its not working) this kinds of error coming.
    F:\shyam\test>javac first.java
    F:\shyam\test>java first
    main class
    DB Set Correctly
    F:\shyam\test>set classpath=C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar
    F:\shyam\test>javac first.java
    first.java:1: package bean does not exist
    import bean.DbBean;
    ^
    first.java:10: cannot find symbol
    symbol : class DbBean
    location: class first
    DbBean dbbean = new DbBean();
    ^
    first.java:10: cannot find symbol
    symbol : class DbBean
    location: class first
    DbBean dbbean = new DbBean();
    ^
    3 errors
    F:\shyam\test>
    In compilation it wont take DbBean class, please help me.
    thanks in advance,
    S.Shyam

  • Servlet API 2.4

    I would like to download a copy of Servlet API 2.4 class files. I know that Servlet API 2.4 is part of the J2EE 1.4 download, but I really don't want (or need) the entire J2EE. So far, all I've been able to do is download the specification.
    There is a link to download Servlet API 2.3 class files, which I am currently using with NetBeans 4.1. I would like to add v2.4 to my NetBeans library.
    Does a link exist to download the Servlet API 2.4 class files and dox? If so, where can I find it? Any help would be appreciated.

    Hi Martin,
    Ivo is right. Web AS 6.40 is J2EE 1.3 compliant and implements Servlet 2.3 specification. In Servlet 2.3 API it’s not explicitly said that the contextInitialized() method in ServletContextListener interface should be called before any servlet or filter is initialized. In this release the ServletContextListeners are notified of context initialization after servlet and filter initialization and thus informing them that web application is ready to process requests.
    Unfortunately there is no workaround as it is implementation dependent, and of course of reasons for backwards compatibility such changes could not be done.
    What concerns your second question is that the J2EE 1.4 (hence, servlet 2.4 API) support is planned for the next release of the Web AS. In that release the contextInitialized event will be thrown before any servlet or filter is initialized.
    Regards,
    Diyan

Maybe you are looking for

  • Error In Solar02 transaction.

    Hi All, I am facing a problem of not able to attach test scripts to Buss tcodes in Solar02,and getting the following error. "Function eCATT Test Configuration is not supported in system/software component ENT/SAP_BASIS" The min package level is being

  • Trying to install Photoshop CC 2014 from inside Craetive Cloud panel and my antivirus says it has a Trojan file in it and it won't install

    I am trying to update and install Photoshop CC 2014 from the Creative Cloud panel and my antivirus stops the installation and says the setup file and a droplet file have a trojan within them.  The Trojan.Win32.Generic.pak!cobra is quarantined in my a

  • Data collection task execution in UCMON

    Dear Friends I am using flexible upload method and load from data streams for data upload. Both methods are assigned to my data collection method which in turn is assigned to the task. When i execute the data collection task in consolidation monitor

  • Window size will not change in open browser window behaviours

    Despite changing the sizes of the window in the edit function of edit open browser window it always opens up as one big page. My code is <p><a href="popup.html"><img src="../Existing business1.jpg" alt="existing1" name="services" width="359" height="

  • Replacing the letters in a string

    I have an odd set of fields for properties for my client. Some have multiple letters which correspond to a code table. How can I loop through the string and replace the letters with words For example A = central air B = ceiling fan C = A/C Unit If th