ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

First web app..!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • First web app..!

    Hi Bryce,



    According to your thread which is post last January to another guy, which I follow about servlet/beans. I set up it on my WDCS 6.0 environment & I didn?t have any source errors with my web application. It initialized everything just fine... After that I have try to run it on the server (WTE 6.0). It?s execute without blowing up but no result are being displayed, as well as console tab shows this horrible errors

    Code:
     
    [11/17/08 13:15:16:781 LKT] 00000029 ServletWrappe A   SRVE0242I: [/index.jsp]: Initialization successful.
    [11/17/08 13:15:17:219 LKT] 00000028 ServletWrappe A   SRVE0242I: [PolicySearchServlet]: Initialization successful.
    [11/17/08 13:15:19:813 LKT] 00000028 ServletWrappe A   SRVE0242I: [/Results.jsp]: Initialization successful.
    [11/17/08 13:15:19:828 LKT] 00000028 ServletWrappe E   SRVE0068E: Could not invoke the service() method on servlet /Results.jsp. Exception thrown : javax.servlet.ServletException: Unable to find a value for "polcn" in object of class "polcPackage.BeanPolcSearch" using operator "."
    	at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:639)
    Unable to find a value for "polcn" in object of class "polcPackage.BeanPolcSearch" using operator "."

    I attached my PolicySearchServlet.java file also, But according to my knowledge it is seems to be OK. Sorry, I can?t exactly say where the exception error is; because of I don?t know how to debug this.

    Similar Error had been occurred to the guy who post the thread at that time. I followed many times the instruction given by you to rectify the errors. But I couldn?t success

    Could u point me in the right direction Please?

    Thanks
    dhanuxp

  • #2
    Re: First web app..!

    Ok! beanList is successfully filled & next line blowing up

    getServletContext().getRequestDispatcher("Results. jsp").forward(request,response);

    Pls help to catch the error of this line!!

    dhanuxp
    Last edited by dhanuxp; November 18, 2008, 10:29 PM.

    Comment


    • #3
      Re: First web app..!

      Is the path correct to Results.jsp? You say that you moved from WDSC to WLT? Are you sure you have Results.jsp in the correct directory? Show me your WEB-XML file.
      Your future President
      Bryce

      ---------------------------------------------
      http://www.bravobryce.com

      Comment


      • #4
        Re: First web app..!

        Originally posted by bryce4president View Post
        You say that you moved from WDSC to WLT?
        Sorry, what do u means??

        Originally posted by bryce4president View Post
        Are you sure you have Results.jsp in the correct directory?
        Yes, It's in WebContent folder - attached

        Originally posted by bryce4president View Post
        Show me your WEB-XML file.
        OK, but i think its OK

        Code:
        <?xml version="1.0" encoding="ISO-8859-1"?>
        <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
            version="2.4">
        
        
            <servlet>
                <servlet-name>PolicySearchServlet</servlet-name>
                <servlet-class>polcPackage.PolicySearchServlet</servlet-class>
            </servlet>
        
            <servlet-mapping>
                <servlet-name>PolicySearchServlet</servlet-name>
                <url-pattern>/PolicySearchServlet</url-pattern>
            </servlet-mapping>
        
        </web-app>
        & I'm Confuse about my Results.jsp file because of error occured when
        getServletContext().getRequestDispatcher("Results. jsp").forward(request,response);
        line is executed..... attached

        thanks
        dhanuxp

        Comment


        • #5
          Re: First web app..!

          Can I see your bean code?
          Your future President
          Bryce

          ---------------------------------------------
          http://www.bravobryce.com

          Comment


          • #6
            Re: First web app..!

            You are using simple JavaBeans with the expression language. This is a good thing but it looks like you've made a mistake somewhere while following the JavaBean specification.

            A JavaBean must have a default constructor and it must have a getter and setter method for each class attribute. The getters and setters are resolved at run time using reflection so they must follow a strict naming standard. If you have a class attribute call "attr" the getter must be called getAttr and the setter must be called setAttr.

            In PolicySearchServlet.java you have the following line of code:
            PHP Code:
            infoBean.setPolcnNumber(polcSearchResults.getString("#POLCN")); 
            yet when you get this value in your jsp you have the following line:
            PHP Code:
            <td><h4>${row.polcn}</h4></td
            This line will look for a method getPolcn on the row object. The setter in the servlet implies it should be getPolcnNumber but this depends what the name of the actual attribute is in the JavaBean.

            The clue was in the exception in your first post.
            Exception thrown : javax.servlet.ServletException: Unable to find a value for "polcn" in object of class "polcPackage.BeanPolcSearch" using operator "."
            It's looking for an attribute called polcn in results.jsp but I'm willing to bet that the actual class attribute is called PolcnNumber.
            Ben

            Comment


            • #7
              Re: First web app..!

              Ben,
              Nice explanation of why I wanted to look at his bean
              Your future President
              Bryce

              ---------------------------------------------
              http://www.bravobryce.com

              Comment


              • #8
                Re: First web app..!

                Wow, Ben your support is AMAZING. It helps me a million and I could sort-out the problem within a one second according to your document. I really appreciate it, tremendously!!!! Thanks a lot Ben.

                Bryce, I sure appreciate you taking your valuable time and helping me!!!
                Thank you so much!!

                O!! One more thing, I want to get advice from you, to refer Recommended relevant (BOOKS) to this technology.

                Once again thank for you, everything.

                dhanuxp
                Last edited by dhanuxp; November 18, 2008, 10:38 PM.

                Comment


                • #9
                  Re: First web app..!

                  My favourite Java author is without doubt Kathy Sierra. She has a very light hearted and witty way of writing technology books so that they don't appear to be technology books at all. Her writing style is very conversational. This, she says, is because a conversation is easier to remember than a lecture because you have had some involvement. She also presents the information in several different formats to help it sink in.

                  For web development try:
                  Head First Servlets and JSP: Passing the Sun Certified Web Component Developer Exam
                  by Bryan Basham, Kathy Sierra, and Bert Bates

                  For core Java try:

                  Head First Java, 2nd Edition
                  by Kathy Sierra and Bert Bates

                  and for a treat on design patterns try:
                  Head First Design Patterns (Head First)
                  by Elisabeth Freeman, Eric Freeman, Bert Bates, and Kathy Sierra

                  These are just a few of my favourites. Effective Java by Joshua Bloch is also supposed to be really good.
                  Ben

                  Comment

                  Working...
                  X