Import statement in JSP

          Hi
          I am maintaining a system done by one of our vendors.
          Application is deployed in WLS 7.0.
          When I imported the Jsp's into my IDE , I got errors where java.util classes are
          used in the JSP's and the import statement is missing.
          Most of the Jsp's are like this,
          It is working fine in the production server.
          In the IDE i am forced to put the import statement and that is what I expect.
          But how can it work in the production server without any issue.
          Can someone advise me on this
          Thanks
          DN
          

<%@page import="java.util.calendar" %>
Oops... forgot the "page" in there ...That's what I get for using GUI's too much!!! :)

Similar Messages

  • Automatic import statements for jsp's?

    Is there a feature in Workshop 9.x's jsp editor that will automatically resolve (or prompt to resolve) classes in use which have not yet been imported into the page? A blue box appeared in 8.x and you could select the class to import, but I'm not finding it in 9.x.

    Greg Foreman wrote:
    Is there a feature in Workshop 9.x's jsp editor that will automatically resolve (or prompt to resolve) classes in use which have not yet been imported into the page? A blue box appeared in 8.x and you could select the class to import, but I'm not finding it in 9.x.Unfortunately no, this is a feature missing from the underlying WTP that
    Workshop is based on for JSP editing.
    Gerald

  • JSP import statement problem

    Hey, I got confused with all import statement with jsp.
    Here is my problem.
    Folder structure:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\webapps\ROOT\WEB\S\A
    This folder contains a.jsp.
    JSP code:
    <%@ page
         language="java"
         import="java.sql.*, MyPackage.DataBase"
         errorPage=". . ."
         contentType="text/html; charset=windows-1251"
    %>
    <%
           Connection connection = null;
         Statement statement = null;
           DataBase dataBase = new DataBase( connection, statement );
    %>
    ...Error message that I get:
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: package MyPackage does not exist
    import MyPackage.DataBase;
                       ^
    An error occurred at line: 104 in the jsp file: /WEB/S/A/a.jsp
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a100_jsp.java:147: cannot resolve symbol
    symbol  : class DataBase
    location: class org.apache.jsp.WEB.S.A.a_jsp
           DataBase dataBase = new DataBase( connection, statement );
            ^
    ...How do I import that class so I can use it?
    Do I need to use useBean?
    What do I need to do?
    Thanks

    DataBase class does not extend java.sql.
    I put this into my jsp page
         import="java.sql.*;"
         import="MyPackage.DataBase;" Here is the error message
    Generated servlet error:
    C:\Program Files\netbeans-4.1\enterprise1\jakarta-tomcat-5.5.7\work\Catalina\localhost\_\org\apache\jsp\WEB\S\A\a_jsp.java:7: 'class' or 'interface' expected
    import MyPackage.DataBase;;
    ^
    1 error
    ...

  • Executing db2 import statement from java

    we have developed an web application using J2EE technology on websphere and DB2 as a backend.
    I have to now develop a utility for data uploading from Excel to DB2. we can do it using IMPORT statement now i want to know is it possible to execute IMPORT statement from JSP/ Servelet and using javabeans.

    Yes, it is possible :-)

  • Import statement in .java files and .jsp files

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import the class I want to use.That is i have to say
    <%@page import="one"%>
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.
    In this case the pSo I am wondering in JSP why it doesn't take the class I am looking for from the classpath .
    Help.

    You have to understand Java scoping rules. In the 1st scenario with the two Java files I am guessing neither one of them begins with a package statement. This means that they belong to the default package. When you compile the compiler uses the classpath to resolve method calls looking in the default package since there was no import statement specified in two.java. JSP is a little different. Now I just read this here in these forums a couple of days ago. Since the classfiles generated from the JSP files are not in the CLASSPATH they are loaded by a different classloader. This is why you have to import all references to all classes in the default package.

  • Import statement in .java files and .jsp files ..correction

    Guys I have few mysteries about this import statement.
    Please correct me if I am wrong.
    1)Suppose if I have a folder c:\SourceFolder it has one.java and two.java files.If I compile one.java then one.class files is created in c:\ClassFolder .Now two.java uses one of the method of one.java,and without using import statement in two.java I am able to compile two.java, and two.class file is created in c:\ClassFolder.I assume that the path of one.class was taken from the CLASSPATH environment variable,hence I there was no need for import statement .........am i right ?
    BUT... in My.jsp,which is in C:\JspFolder, if I want to use one.class,then I have to specifically import one.class in My.jsp .That is i have to say
    <%@page import="one"%>
    in My.jsp.
    and since the classpath is C:\ClassFolder ,it finds one.class in the C:\ClassFolder and MyJsp is compiled sucessfully.(Note that My.class is created in a folder different from c:\ClassFolder )
    But I am wondering why was there no need for me to import one.class in two.java.
    (Note I am using JDeveloper and Apache server)
    Please help.

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • Import statement in a JSP

    How do you write an import statement in a JSP? I did this but it isn't working...
    <%!
    import="java.util.Calendar"
    %>
    Thanks.
    P.S. - I got a dog on Saturday!

    <%@page import="java.util.calendar" %>
    Oops... forgot the "page" in there ...That's what I get for using GUI's too much!!! :)

  • JSP import Statement importing a Class File giving ERROR

    Hey guys,
    There is a problem to which I dont know the reason,
    Consider the code below:
    <%@ import Converter, ConverterHome %>
    It gives me a Compile Time error of this type:
    '.' Required in import Converter ;
    but when i put these classes in a package suppose "converter"
    and the above import statement like this :
    <%@ import converter.Converter,converter.ConverterHome%>
    It gives me no error
    So whats the reason behind this? Cant I compile a JSP program by refrencing classes without in any package?
    please Reply
    Thanks in advance..

    So whats the reason behind this?
    Cant I compile a JSP program by refrencing classes without in any package?No, I do not beleive you can, is you are using Java 1.4. In 1.4, you can only reference classes in the Default Package (none) from other classes in the default package. If you are in a package, then you can not import from the default package. And this is for ALL java classes, not just JSP and Serlets. Since the JSP servlet would be part of a package (which depends on the server you are using) you will need to put your classes into packages to import them...

  • Which one better to use - jsp:useBean or import statement

    Hi,
    I just want to know that which one is better to use jsp:useBean or import statement .
    I can instantiate and call method of myclass -
    1) by importing the class through import tag in jsp as <%@page import="myclass"%. or
    2). by using <jsp:useBean tag....
    i have these two option to do the same thing. i know that basically useBean is used to call setter and getter method of bean class and but it can be used to call a normal java file that have some logic .
    so what should i used , which one is better and why?
    useBean provides scope and object instance so no need to create object by new operator. and with import you have to create an instance .
    but which tag should i use in my jsp?
    i am confused???

    ok, means i can use jsp:useBean tag for all my
    classes that are not actually bean. so it will be
    instantiated at run time and provide efficiency .No. Jsp:useBean is used for java bean components.
    >
    but when should i use import statement in my jsp and
    it happen at translation time so will it create any
    type of burden for my code if i import multiple
    classes.For non-java beans, you need to import the classes, period.
    It's not a burden, it's a necessity.

  • Jsp declaration and import statement

    Hi All
    I have some problems with JSP.
    I have wrtten a declaration in jsp like this.....
    <%@ page language="java"%>
    <%!
    Date date = new Date();
    List al new ArrayList();
    public List getList(){
    al.add("Hi");
    return al;
    %>
    The List is-> <%= getList()%>
    Note that i did not import anything, it gives the output without any compile time/runtime error. How it is happening?
    If i write any thing in scriplets.......like List, Date, it is giving compile time error asking to import this.
    I am using weblogic8.1
    May i get the correct answer for this ASAP?
    Thanks and Regards
    Kasim
    [b]

    weblogic includes certain import statements in the JSP page when it is compiled.
    That is why u r not getting an error some times!!
    Check your weblogic documentation to find more details abt that
    But it is better to include the import statements , so the code will work in any server.

  • Pls help!  How to put JSP import statement...

    Hi, I just created a simple iView JSP that imports htmlb classes and now I'd like to import my own java classes onto it.  For example, in my other projects, my JSP's have <%@ page import="project28.practice.contextClass" %> on top of the page.  I currently have a file called practice.jar 
    If I want to put this import statement into my simple iView JSP and use it, what would I have to do/configure?, do I have to transform it into a .par file?  Or can I  transport the jar file to the portal?  Any changes on NetWeaver?
    I am new to this so any detailed help or suggestions are greatly appreciated!
    Thanks again,
    Baggett

    Hi Detlev, thank you for your response!  I'd like to include more details of my situation right now:  I have 2 projects on NetWeaver:
    Project#1: Java Web application Project. (jar files, WEB-INF, WEB-INF/web.xml, JSP's...)
    Project#2: Portal Application Project. (JSPDynPage, sap plugins, PORTAL-INF/portalapp.xml, JSP)
    I'd want my JSP file in Project#2 to call some classes from the jar files of Project#1. 
    From my understanding, to do this I need to make a .par file out of Project #1 and then upload the par file to my SAP EP6.0 so that my future JSP's can import classes from it.  Am I correct?
    I am confused right now as to how to really do this.  On Netweaver, I am getting a Error when I try to do: File --> New --> Project --> Portal Application --> Create a Portal Application Project > I then enterProject Name: TestProject28, Project root folder: c:\TestProject\webapps\project1 
    --> "ERROR: Invalid project description, Reason:An error has occured while trying to create the project structure"
    If possible can you please provide detailed instructions on how to configure or build a par file out of my java web application stated above?
    Thank you so much for your time and help!
    Baggett

  • Import Statement without ID Specification

    There is an import statement
    IMPORT tab g_acc_tab FROM MEMORY.
    While UCChecking it.. it saying that
    import statement without id specification is only used for the sake of r/2 ......
    Can i Comment it ? If so won't my application  go into dump while running on 6.0cc???

    It has to do with packages. Most java classes are in a package, the name of which must conform to its place on the filesystem relative to the classpath. By that I mean that if you have com.mystuff.One.java, it must be in a folder com/mystuff where com is located somewhere in the classpath.
    What you've done is a little different. I'm assuming a couple of things:
    1. you have no package declaration at the top of one.java or two.java
    2. you have the current directory "." in your classpath.
    Java has the concept of the "default package", which covers classes without a declared package, and in your case is the current directory.
    So when you're in c:\sourcefolder and run the compiler, then "."="c:\sourcefolder", and that directory is part of the default package. No import statements are necessary for classes that are in the same package. This is why two.java can call methods in one.java without an import statement.
    When you run your jsp, the "current directory" part of your classpath is not c:\sourcefolder, but some other value (probably the directory you start your jsp engine from) You will have to import all non-java-library classes because the jsp itself becomes a java class, with a package that is determined by the jsp engine.

  • Unused packages in import statement

    Guyz,
    Can anyone throw some light on this ?
    Does using a lot of unused packages in import statement of a jsp affects its performance in terms of page loading ?
    Thanks.

    I have just found the answer for my question in another forum.
    Please visit:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=15&t=000240
    Thanks.

  • What to import in the JSP file??

    I want to use jsp and xsl to convert xml to html in order to display the file. But I come across a problem, I don't what should be import into the jsp file. Should I import these? <%@ page import="org.xml.sax.*" %>
    <%@ page import="org.apache.xalan.xslt.*" %>
    Since I'm not very good at this field, can anybody give me some suggestion to hlep me to work it out?
    thanks~

    One thing is sure. Whatever the classes you are going to use, need to be imported in your Jsp.
    There is no need for different import statements. You can write in a single import statement (comma separated).
    So, forget about the import statements and do your coding, finally you can look at the code and decide what classes (packages) you need to import.
    I think you need to import
    org.xml.sax.*;
    org.xml.sax.helpers.*;
    import javax.xml.parsers.*;
    Hope this helps.

  • Import statement giving error

    Hi All,
    I am writing a JSP page, and need to instantiate an object of a certain class within my package, in my JSP page.
    How do I do that? Do i use the <%import = "Myclass.class" %>
    I am using Sun Forte.. and the directory is myprojects/test/Classes/MyClass.java
    so how would the import statement look like?
    Thanks
    Kal.

    Kal,
    You would use the page directive with the import attribute. It looks like this: <%@page import="MyPackage.MyClass"%> or if your class is in the default package <%@page import="MyClass"%>. It is suggested that all classes used in JSP be packaged. (That is they include the package statement in thier source file and reside in a directory structure resembling the package name.)
    Cliff

Maybe you are looking for

  • How do I stop Launchd from opening so many other processes?

    My computer has been running slow for some time even with without any applications open. On a whim, I created a new login account and it runs lickety split. I compared the Activity Monitor of both accounts and the old account is running 40 other proc

  • Reversing a document using the bapi 'BAPI_ACC_DOCUMENT_REV_POST'

    Hi All, I have posted a document using the FM 'BAPI_ACC_DOCUMENT_POST' and it is working fine . How can I reverse the same posted document using the FM 'BAPI_ACC_DOCUMENT_REV_POST'? What are the mandatory parameters to be filled? Can anyone explain m

  • OK to use Aperture to maintain iPhoto Referenced Library

    I have Aperture and iPhoto. We are an OSX and Windows household. But thanks to the Windows 8 debacle, my wife (the diehard Windows user) has abandoned her PC with all regard to photos and videos (viewing, editing, sharing). Now, I use Aperture most o

  • Need Help Programmatically setting Page Size for printing to Adobe PDF

    We are upgrading from Adobe 5 to Adobe 9.  In Adobe 5, we set a few parameters in the __pdf.ini file to create a document with a specific Page Size.  For Example: [Acrobat PDFWriter] PDFFileName= bDocInfo=0 Orient=1 bExecViewer=0 cpmarginwhole=18 cpw

  • Including image in FO fille to generate PDF using FOP

    Hi, we are trying out generating PDF files in JDK1.1.7 environment by using FOP. While we are testing we are encountering problem with writing images. In .fo file if the image is included, it is giving the following exception. We are of no clue regar