Java Servlet Argument is Null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • SDyke
    New Member
    • Aug 2006
    • 17

    Java Servlet Argument is Null

    In the following servlet code I need to assign the variable(drawin gnumber) in the filePath:

    protected void doPost(HttpServ letRequest arg0, HttpServletResp onse arg1) throws ServletExceptio n, IOException {
    String drawingnumber = arg0.getParamet er("dwgno");
    Drawing drawingString = Drawing.getDraw ing(drawingnumb er);

    String drawingrev = arg0.getParamet er("dwgrel");
    ServletOutputSt ream out = arg1.getOutputS tream();
    arg1.setContent Type( "applicatio n/pdf" );

    HttpSession session = arg0.getSession (true);

    String filePath = "//gvas400/home/sde/pdffiles/" + drawingnumber + "P1.pdf";

    However this code generates an error:
    Could not invoke the service() method on servlet ViewDrawing. Exception thrown : java.io.FileNot FoundException: \\gvas400\home\ sde\pdffiles\nu llP1.pdf (The system cannot find the file specified)

    It puts a null where the drawingnumber should be.
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by SDyke
    In the following servlet code I need to assign the variable(drawin gnumber) in the filePath:

    protected void doPost(HttpServ letRequest arg0, HttpServletResp onse arg1) throws ServletExceptio n, IOException {
    String drawingnumber = arg0.getParamet er("dwgno");
    Drawing drawingString = Drawing.getDraw ing(drawingnumb er);

    String drawingrev = arg0.getParamet er("dwgrel");
    ServletOutputSt ream out = arg1.getOutputS tream();
    arg1.setContent Type( "applicatio n/pdf" );

    HttpSession session = arg0.getSession (true);

    String filePath = "//gvas400/home/sde/pdffiles/" + drawingnumber + "P1.pdf";

    However this code generates an error:
    Could not invoke the service() method on servlet ViewDrawing. Exception thrown : java.io.FileNot FoundException: \\gvas400\home\ sde\pdffiles\nu llP1.pdf (The system cannot find the file specified)

    It puts a null where the drawingnumber should be.
    That is because drawingnumber actually is null here.
    Check the JSP/Html page that is calling this servlet.
    Does it have a component called "dwgno"? With the same case and on the form that is submitted?

    Comment

    • SDyke
      New Member
      • Aug 2006
      • 17

      #3
      Originally posted by r035198x
      That is because drawingnumber actually is null here.
      Check the JSP/Html page that is calling this servlet.
      Does it have a component called "dwgno"? With the same case and on the form that is submitted?
      I did not have my bean(id dwgno) and getProperty that holds the drawing number
      located on the form with the submitt button.

      Now I have on the JSP I have a form with a submitt button and a bean and a getProperty that holds and displays a drawing number. The bean id is dwgno.

      I still get the null string value for my drawing number.

      Comment

      • SDyke
        New Member
        • Aug 2006
        • 17

        #4
        Java Servlet Argument is Null

        In the following servlet code why would dwgString be null?

        protected void doPost(HttpServ letRequest arg0, HttpServletResp onse arg1) throws ServletExceptio n, IOException {
        String dwgString = arg0.getParamet er("dwgno1");

        Comment

        • r035198x
          MVP
          • Sep 2006
          • 13225

          #5
          Originally posted by SDyke
          I did not have my bean(id dwgno) and getProperty that holds the drawing number
          located on the form with the submitt button.

          Now I have on the JSP I have a form with a submitt button and a bean and a getProperty that holds and displays a drawing number. The bean id is dwgno.

          I still get the null string value for my drawing number.
          What is dwgno supposed to be? Is it a value that is entered by the user in a JSP?

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by SDyke
            In the following servlet code why would dwgString be null?

            protected void doPost(HttpServ letRequest arg0, HttpServletResp onse arg1) throws ServletExceptio n, IOException {
            String dwgString = arg0.getParamet er("dwgno1");
            Please do not double post.

            Comment

            • SDyke
              New Member
              • Aug 2006
              • 17

              #7
              Originally posted by r035198x
              What is dwgno supposed to be? Is it a value that is entered by the user in a JSP?
              The first page of my web app is a JSP where the user can type in a drawing number and click a button to make a connection to an AS400 database to gather info based on number entered. This button opens up a second JSP displaying the drawing number and related data. There is a button on this page that fires a servlet that is used to view the PDF file of the drawing. I need to use the displayed drawing number in the path string that opens the PDF file.

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by SDyke
                The first page of my web app is a JSP where the user can type in a drawing number and click a button to make a connection to an AS400 database to gather info based on number entered. This button opens up a second JSP displaying the drawing number and related data. There is a button on this page that fires a servlet that is used to view the PDF file of the drawing. I need to use the displayed drawing number in the path string that opens the PDF file.
                Post the code for the JSP that is accepting the parameter then. Are you sure you have the input box on the form that you are submitting?

                Comment

                • SDyke
                  New Member
                  • Aug 2006
                  • 17

                  #9
                  Originally posted by r035198x
                  Post the code for the JSP that is accepting the parameter then. Are you sure you have the input box on the form that you are submitting?
                  No I did not have the input box on the form. This was my problem. I have it fixed and working somewhat now. Thanks for the help.

                  Comment

                  Working...