JSP import problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ashsa
    New Member
    • Feb 2007
    • 45

    JSP import problem

    Hi,

    I am using this statement exactly in my JSP page.
    Code:
    <%@ page import="java.util.*, java.lang.*" %>
    But when i view the equivalent servlet generated, it is like this :
    Code:
    import java.util.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
    import java.lang.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
    And the second import is always getting to the end of the first import statement so that it is also included as a part of the single line comment '//'. This happens with all the JSP imports.

    Could anyone figure out where the problem lies ... Its really urgent.

    Many Thanks for any help .
  • dmjpro
    Top Contributor
    • Jan 2007
    • 2476

    #2
    what's the problem with the conversion?????

    kind regards.
    dmjpro.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by ashsa
      Hi,

      I am using this statement exactly in my JSP page.
      Code:
      <%@ page import="java.util.*, java.lang.*" %>
      But when i view the equivalent servlet generated, it is like this :
      Code:
      import java.util.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
      import java.lang.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
      And the second import is always getting to the end of the first import statement so that it is also included as a part of the single line comment '//'. This happens with all the JSP imports.

      Could anyone figure out where the problem lies ... Its really urgent.

      Many Thanks for any help .
      Are you getting an error then?

      Comment

      • ashsa
        New Member
        • Feb 2007
        • 45

        #4
        Originally posted by dmjpro
        what's the problem with the conversion?????

        kind regards.
        dmjpro.

        The second import statement gets to the end of the first one like

        Code:
        import java.util.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]#import java.lang.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
        so that the second one is always commented along with the comment of the first import statement with a special character (shown as a square in my editor)
        inserted at the place where you see '#' here. Thus only the class being imported first is being imported and it raises an error when there is a reference to the classes imported second or later .


        Hope thats clearer ..

        Comment

        • dmjpro
          Top Contributor
          • Jan 2007
          • 2476

          #5
          now what 's ur headache with these comment lines???

          r u trying to do something which is not due to these unexpected comment lines????


          kind regards.
          dmjpro.

          Comment

          • r035198x
            MVP
            • Sep 2006
            • 13225

            #6
            Originally posted by ashsa
            The second import statement gets to the end of the first one like

            Code:
            import java.util.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]#import java.lang.*; //[ /hrms/budgetsAndCosts_HRMS.jsp; Line: 1]
            so that the second one is always commented along with the comment of the first import statement with a special character (shown as a square in my editor)
            inserted at the place where you see '#' here. Thus only the class being imported first is being imported and it raises an error when there is a reference to the classes imported second or later .


            Hope thats clearer ..
            Do you get an error when you run your JSP?

            Comment

            • ashsa
              New Member
              • Feb 2007
              • 45

              #7
              Originally posted by dmjpro
              now what 's ur headache with these comment lines???

              r u trying to do something which is not due to these unexpected comment lines????


              kind regards.
              dmjpro.
              If this is the import statement in the JSP page,

              Code:
              <%@ import="java.util.Date,java.util.Calendar" %>
              the servlet generated shows it like

              Code:
              import java.util.Date; //[ test.jsp; Line: 1]import java.util.Vector; //[ test.jsp; Line: 1]
              So, only Date is imported and not the Vector.
              The second import is commented after
              Code:
              import java.util.Date;
              as

              Code:
              //[ test.jsp; Line: 1]import java.util.Vector; //[ test.jsp; Line: 1]

              Comment

              • ashsa
                New Member
                • Feb 2007
                • 45

                #8
                Originally posted by r035198x
                Do you get an error when you run your JSP?
                I get the error when am referring to the class which comes in the second import statement. Since the second import is commented along with the first import's sidenote, its not imported at all..

                Thanks for any Help

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  Originally posted by ashsa
                  I get the error when am referring to the class which comes in the second import statement. Since the second import is commented along with the first import's sidenote, its not imported at all..

                  Thanks for any Help
                  Which error did you get specifically?

                  Comment

                  • dmjpro
                    Top Contributor
                    • Jan 2007
                    • 2476

                    #10
                    why did not u tell the particualr problem before?????

                    it does not happen to me.
                    i m using Oracle Jdeveloper for JSP Editor.
                    what r u using????

                    if this happens to u then change it into one packege import instead of more that one packge or class import.

                    one more thing i want to mention that directly come to the point.... instead of complicating the problem..
                    and i hope u ll not do that again.
                    have a good day.

                    kind regards.
                    dmjpro.

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by ashsa
                      I get the error when am referring to the class which comes in the second import statement. Since the second import is commented along with the first import's sidenote, its not imported at all..

                      Thanks for any Help
                      I suspect it's just an editor problem; my guess is that those lines are just
                      terminated by a newline '\n' character and your editor chokes on it. If your
                      JSP runs fine I am right; if it doesn't there's a nasty bug somewhere in your
                      JSP compiler.

                      My JSP is more than rusty. Is it allowed to import more than one package
                      using a comma as a package name separator? Can you import those packages
                      using separate import statements, one of each package? Does it run then?

                      kind regards,

                      Jos

                      Comment

                      • ashsa
                        New Member
                        • Feb 2007
                        • 45

                        #12
                        Originally posted by r035198x
                        Which error did you get specifically?
                        cannot resolve symbol

                        Comment

                        • ashsa
                          New Member
                          • Feb 2007
                          • 45

                          #13
                          Originally posted by dmjpro
                          why did not u tell the particualr problem before?????

                          it does not happen to me.
                          i m using Oracle Jdeveloper for JSP Editor.
                          what r u using????

                          if this happens to u then change it into one packege import instead of more that one packge or class import.

                          one more thing i want to mention that directly come to the point.... instead of complicating the problem..
                          and i hope u ll not do that again.
                          have a good day.

                          kind regards.
                          dmjpro.
                          Very sorry for not being clear ..
                          After some hours of head break on it found that the error has been due to a missing new keyword somewhere .. Now thats working fine ...


                          And Thanks a lot your valuable concern.. Am using Editplus trial version and it shows the newline characters as unidentified chars..

                          Comment

                          • ashsa
                            New Member
                            • Feb 2007
                            • 45

                            #14
                            Originally posted by JosAH
                            I suspect it's just an editor problem; my guess is that those lines are just
                            terminated by a newline '\n' character and your editor chokes on it. If your
                            JSP runs fine I am right; if it doesn't there's a nasty bug somewhere in your
                            JSP compiler.

                            My JSP is more than rusty. Is it allowed to import more than one package
                            using a comma as a package name separator? Can you import those packages
                            using separate import statements, one of each package? Does it run then?

                            kind regards,

                            Jos
                            Your suspicion about my editor is cent percent correct. My editplus trial version shows newlines as squares.. atleast that it shows !!

                            Regarding the import statement, its always valid to import more than one package using a comma as a package name separator. And as i understand theres hardly any difference between importing watever u want through a single import and importing one through each statement.

                            Many Thanks for the support ..

                            Comment

                            • JosAH
                              Recognized Expert MVP
                              • Mar 2007
                              • 11453

                              #15
                              Originally posted by ashsa
                              Regarding the import statement, its always valid to import more than one package using a comma as a package name separator. And as i understand theres hardly any difference between importing watever u want through a single import and importing one through each statement.

                              Many Thanks for the support ..
                              Ok, so we skip the editor for now as a cause (download vim instead!). Do your
                              JSPs work when you use separate import statements, one for each package?
                              (note that you never need to import java.lang.*, i.e. it's "self-imported" by javac).

                              If separate import statements do work, you're most probably facing a bug in
                              the JSP compiler. Which one are you using and what version?

                              kind regards,

                              Jos

                              Comment

                              Working...