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.

Similar Messages

  • 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.

  • Difference Betwen #include statement and Import statement

    What is the Difference between #include and Import statements!

    Why do you need to shout! Are you unware that English has a question mark that is used at the end of a question sentence! Java doesn't have #include! It only has import!
    Import in Java simply tells the compiler that when you say, for example, List, you mean, for example, java.util.List! It does not affect the generated class file in anyway!
    #include in C/C++ causes the body of the reference file to be inserted into the compilation stream! So, unlike Java's import, that file actually gets compiled into the final output!

  • Supplementary customs declaration and Import code number

    Hi guys,
    I've a question from my colleagues from export/import...
    They are working with the Supplementary customs declaration. Now it can happen that the Import code number change in the time when starting with the declaration and until sending it to the customs authority. So it can happen, that the "old" number is still in the document.
    Custom authority say, that we have to send it with the new number. But also if you're in change mode in the Supplementary customs declaration it isn't possible to change the Import code number.
    Any idea?
    Thank you in advance.
    Kind regards
    Thomas

    Did you already read whats behind the blue info button that is on top of slection screen in VIU4 transanction?
    Where exactly do you have the problem in this screen?
    Do you have an external file with commodity codes, description ..?

  • Jsp:declaration and request

    Can we use request in jsp:declaration?
    In my program request cannot be recognised unless it
    is inside of <jsp:scriptlet>
    So what do we set inside of jsp:declaration?

    The code that you put inside the jsp:scriptlet is inside a method called _jspService(request, response).  The request method is local to the service method.
    To get it into the declared method you have to pass it as a parameter to the method:
      String getName(HttpServletRequest request) {
        String str = (String)request.getAttribute("name");
        return str;
      }and then call it like:
      String name = getName(request); That being said, you should do whatever you can to remove the whole method declarations from the JSP you can. You can do what you have above by using JSTL and EL:
        ${request.name}No method declarations, no passing request around, nice clean code. Look up JSTL and EL (Expression Language).

  • Conditional compilation and import statements

    I have a web application written in Flex and I'm trying  to build an AIR application from the same code base using conditional  compilation.
    In the AIR application, I need to have import statements  such as the following:
    import flash.data.SQLConnection;
    import  flash.filesystem.File;
    but I cannot have these import statements in the web  application because they are AIR only classes.
    I thought I could use conditional compilation to  overcome this issue but then I read the following on page http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html:
    "You cannot use constant Boolean values to conditionalize metadata or import statements."
    If that's the case, how can I have common codebase for Flex based web as well as desktop applications? Has anyone solved this conundrum?
    Thanks,
    Dilip

    DilipShah, as far as I see the classes are still included if referenced by import.
    Example:
    I have this statement in my class A
    if(CONFIG::platform == "ios") {
                        import B;
    I can see in linkreport that class B is still included and is included because A is referencing it.
    Flex harUI, classes are included into final swf file if any other class is referencing it through import even though not using it. I've experimented with it quiet a bit.

  • Package scope and import statements

    Hi everubody,
    I'm studing a code: foo.java written by sb. else. In the code, I have:
    package com.dir1.dir2.dir3;
    import com.dir1.dir4.code1;
    import com.dir1.dir5.code2;
    The code: foo.java exists in the directory: com/dir1/dir2/dir3 as expected. However, in the import statements, there is NO dir4 and dir5 under com/dir1? Shouldn't the import statements be relative to the directory of package?
    Guess I'm missing a point here... Any help is greatly apprecited.

    When you import:
    import co.mycompany.my.MyClass
    then MyClass should reside in the directory:
    co/mycompany/my, right?Right. Somewhere in the classpath there would have to be that directory structure. Again, that could be an actual directory name, or a path name in a Jar.
    Then if the code: foo.java resides in the directory:
    com/dir2/dir3 with the:
    package com.dir1.dir2.dir3;
    How the compiler and JVM finds the code MyClass
    (which you imported in foo.java)?Thru the magic known as the classpath.

  • Jsp - classes and import

    Hello,
    i got some problems with a jsp - file: i have to write a class and then import it onto a server
    i would appreciate quick answers - if someone could help me - i`ll pay
    i`ll also go into more details - but i think thats some basic stuff for you guys

    I don't see any question in your topicstart?
    Also willing to pay makes really no sense here at a public discussion forum. Better use rentacoder.com or freelancers.net instead.

  • Export and import statements

    HI,
    I've developed a report which calls another standard report, which exports values to memory.
    i will import those values to my program. I am calling that standard program in b/g mode.
    I've used wait statement to make the program to wait for a while to update the exported values in the database cluster. This is working fine for small amount of data like 100 records like that.
    It's not working when data is more like more than 500 records. If i run the report in debugging mode i am getting output. But if i run directly (F8) the values are not exporting to memory and not getting the output. Not able to import data with F8, even i increase the wait time and used commit statment in the program.
    what wud be the problem and how can we rectify it?
    points assured for quick response.
    regards,
    Pra

    Hi Praneet,
    Consider the use of CALL FUNCTION <function> STARTING NEW TASK for your background process. Add
    PERFORMING subr ON END OF TASK.
    to continue processing.
    Put the export/import data into function interface.
    Regards,
    Clemens
    Message was edited by:
            Clemens Li

  • Export and import statement.

    what will be exported after the execution of follwoing 3 lines?
    It will be ship-to party or sold-to party?
    CUST1   =  tkomk-kunnr.
    CUSt2    =  TKOMK-KUNWE.
    export CUST1 to memory id cust2
    what is use of second statement in above lines?

    Hi,
    CUST1 = tkomk-kunnr.    --->  Contains Ship to party value
    CUSt2 = TKOMK-KUNWE.  --->  Contains Sold to party value
    Export CUST1 to memory id <b>cust2</>  -
    > Exporting the ship to party value to memory .   The bolded Cust2 is the name of the memory id it holds the value of cust1 i.e., Ship to party.
    So.. Ship to party value will be exported. and CUST1 contains Ship to party and CUST2 contains Sold to party value and CUST2of memory ID contains ship to party values.
    CUST2 of memory ID and CUST2 contains different values.
    Br,
    Laxmi

  • Import statement .. what does it do ??

    Hi All,
    What is IMPORT statement doing ??
    IMPORT order_items_in to w_order_items_in from MEMORY ID
    'FREEGOODSTERMS'.
    can you kindly explain what this statement is doing ?
    I was by my friend that this is used to pass order_items from one session to this sesssion, but when I searched for FREEGOODSTERMS, I could find export after this statment. I was wondering how can import me first and then export.
    Please let me know.
    Thanks
    venkat.

    Hello Venkat,
    Sorry for late reply..
    Please see the program which other program submitting somewhere.
    if they are using multiple purpose then export and import statement may possible in one include.
    Best way just use where used list for that include and other programs searching like export and submit..
    For better understanding about export and import then see the below sample programs.
    Create one program and paste below code :
    REPORT  ZTEST_AMEM1.
    tables : lfa1.
    data : begin of i_lfa1 occurs 0 ,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of i_lfa1.
    start-of-selection.
    select lifnr
           name1
           land1 from lfa1
           into table i_lfa1 up to 100 rows.
    Export
    export i_lfa1 to memory id 'SAP'.
    submit ztest_amem2 and return.
    write:/ 'hello'.
    Now create one more program  and paste below code :
    REPORT  ZTEST_AMEM2.
    data : begin of j_lfa1 occurs 0,
           lifnr like lfa1-lifnr,
           name1 like lfa1-name1,
           land1 like lfa1-land1,
           end of j_lfa1.
    start-of-selection.
    import i_lfa1 to j_lfa1 from memory id 'SAP'.
    loop at j_lfa1.
    write:/ j_lfa1-lifnr,j_lfa1-name1,j_lfa1-land1.
    endloop.
    Thanks
    Seshu

  • A problem from "import" statement

    When I was doing some test on "package" and "import" statement, I had a problem.
    1 I compiled one class:
    package com.sheng.population;
    public class A {
         public static int sum (int k, int l) {
              return (k+l);
    2 I tried to call the method 'sum' in A:
    import com.sheng.population.*;
    public class B {
         public static void main(String[] args){
              int i=9;
              int j=100;
              int k = A.sum(i, j);
              System.out.println(k);
    Then I got the error message:
    "B.java:7: cannot access A
    bad class file: E:\newjava\analysis\LDmeasure\A.java
    file does not contain class A"
    Only after I changed the import statement to "import com.sheng.population.A;" , then it worked.
    I just do not know why the '.*' does not work?
    Thanks

    Let's say your directory structure is "e:\newjava\com\sheng\population\A.class" and "e:\newjava\analysis\LDmeasure\A.java"
    If your Classpath is .;e:\newjava and when you compile, your current directory is e:\newjava\analysis\LDmeasure then you have A.java and A.class in your Classpath. When you use "import com.sheng.population.*;" the compiler does not know you mean com.sheng.population.A. The compiler finds A.java and thinks it is the A class that the B class needs. When it tries to compile A.java it finds the class name is com.sheng.population.A which causes the error. When you use "import com.sheng.population.A;" the compiler does not try to use A.java.
    If you are keeping the source code in a different directory from the compiled classes, then you should not have the source code in the Classpath. So, if you make sure the current directory is not e:\newjava\analysis\LDmeasure then it should compile.

  • Additions required in portalapp.xml to import statements in JSPDynPage

    Hi all,
    What additions are required in portalapp.xml and import statements in JSPDynPage to include the equivalent of following JCO Clientservice in EP6 SP11?
    com.sap.portal.runtime.application.jcoclient.jcoclient
    The piece of code requiring the above is also given below.
    IJCOClientService clientService = (IJCOClientService) PortalRuntime.getRuntimeResources().getService("com.sap.portal.runtime.application.jcoclient.jcoclient");
    Thanking you ,
    Med venlig hilsen/Best regards
    Prabahar N.R

    Hi Prabahar,
    portalapp.xml: Add "com.sap.portal.runtime.application.jcoclient" to the SharingsReferences.
    import: com.sapportals.portal.prt.service.jco.IJCOClientService
    Hope it helps
    Detlev

  • 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 .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.

Maybe you are looking for