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.

Similar Messages

  • JSP - difference between extending class and importing class

    In the following scenario
    class A
    private static String con;
    Case 1
    ==========
    class B extends A
    Case 2
    ===========
    import A;
    class C
    A objA = new A;
    What will be the difference in Case 1 and Case 2 on accessing the variable con.
    thanx
    Venki

    >
    If i am not wrong, the above line should be private
    static variables are not inherited.
    NO, AFAIK, static variables, private or otherwise arent inherited. Please note that doesnt mean, its not available in the sub-class. Infact it is. However you cannot override or hide them ie polymorphism isnt applicable to static members which is what , IMO, inheritance is all about. Its logical, when you think about it, polymorphism is applicable for objects and static is a class thinggy, has nothing to do with objects.
    cheers,
    ram.

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

  • How to export and import java class?

    -- OS: RHEL5, Oracle 10.2.0.5
    Dear!
    I've got one schema contains only java and java-source, with some table object.
    Now, I'd like to find the way to export java class and import into the other database, however, I can not find the best way without datapump. My purpose is only export java class (not include java source, the other object). I tried to use dbms_metadata, but not worked with java.
    May you show me some thing about that?
    Thank you!

    Thank you for your reply!
    As I posted below, I tried to get from dbms_metatdata, but could not. So, please view an example:
    system@CLOUD> col object_name format a15
    system@CLOUD> col object_type format a15
    system@CLOUD> select object_name, object_type, status from dba_objects
      2  where owner='CLOUD_ADMIN'
      3  and object_type like 'JAVA%'
      4  and object_name like 'Ba%'
      5  /
    OBJECT_NAME     OBJECT_TYPE     STATUS
    Base64          JAVA CLASS      VALID
    Base64          JAVA SOURCE     VALID
    system@CLOUD> select dbms_metadata.get_ddl('JAVA CLASS','Base64','CLOUD_ADMIN
      2  from dual;
    DBMS_METADATA.GET_DDL('JAVA_CLASS','BASE64','CLOUD_ADMIN')
      BEGIN NULL; END;Well, the dbms_metadata did not get ddl from java class, but only Java-Source!
    Example:
    system@CLOUD> ed
    Wrote file afiedt.buf
      1  select dbms_metadata.get_ddl('JAVA_SOURCE','Base64','CLOUD_ADMIN')
      2* from dual
    system@CLOUD> /
    DBMS_METADATA.GET_DDL('JAVA_SOURCE','BASE64','CLOUD_ADMIN')
       CREATE JAVA SOURCE NAMED "CLOUD_ADMIN"."Base64" AS
    // To modify this template, edit file JavaS.txt in TEMPLATE// directory of SQL
    Navigator//// Purpose: Briefly explain the functionality of the procedure//// MO
    DIFICATION HISTORY// Person      Date    Comments// ---------   ------  --------
    -----------------------------------//import java.lang.*;import java.io.Unsupport
    edEncodingException;public class Base64 {       //private static int FACTOR =6;
    private final static String LANGUAGE = "ISO8859_1";        public static String
    cvt = "opqrstEFGHIJKLMNOPQRSAB3456CDTUVWXYZabcdefghijklmnuvwxyz012789-_";
      private static int fillchar1 = '.';        private static int fillchar2 = '.';
            public Base64(){};        public static String byteArrayToString(byte[]
    input)
    throws UnsupportedEncodingException{        if (input != null) return new String
    (input, LANGUAGE);        else return null;        }        public static byte[]
    stringToByteArray(String input) throws UnsupportedEncodingException{        if
    (input != null) return input.getBytes(LANGUAGE);        else return null;
    }        public  static String encode(String s) {            try {
           byte[] data = stringToByteArray(s);                    int c;
            int len = data.length;                    StringBuffer ret = new StringB
    uffer(((len / 3) + 1) * 4);                    for (int i = 0; i < len; ++i) {
                          c = (data[i] >> 2) & 0x3f;                        ret.appe
    nd(cvt.charAt(c));                        c = (data[i] << 4) & 0x3f;
                if (++i < len)                            c |= (data[i] >> 4) & 0x0f
    ;                        ret.append(cvt.charAt(c));                        if (i
    < len) {                            c = (data[i] << 2) & 0x3f;
               if (++i < len)                                c |= (data[i] >> 6) & 0
    x03;                            ret.append(cvt.charAt(c));
      } else {                            ++i;                            ret.append
    .....

  • Using java class and variables declared in java file in jsp

    hi everyone
    i m trying to seperate business logic form web layer. i don't know i am doing in a right way or not.
    i wanted to access my own java class and its variables in jsp.
    for this i created java file like this
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static void main(String args[]){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                String  str = rs.getString("Name");
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
    }next i created a jsp where i want to access String str defined in java class above.
    <%--
        Document   : fisrt
        Created on : Jul 25, 2009, 3:00:38 PM
        Author     : REiSHI
    --%>
    <%@page import="ris.NewClass"%>
    <%@page contentType="text/html" pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
        </head>
        <body>
            <h1><%=str%></h1>
        </body>
    </html>I wanted to print the name field extracted from database by ResultSet.
    but it gives error cannot find symbol str.
    please help me to find right way to do this.
    i am using netbeans ide.

    Very bad approach
    1) Think if your table contains more than one NAMEs then you will get only the last one with your code.
    2) Your String is declared as local variable in the method.
    3) You have not created any object of NewClass nor called the method in JSP page. Then who will call the method to run sql?
    4) Your NewClass contains main method which will not work in web application, it's not standalone desktop application so remove main.
    Better create an ArrayList and then call the method of NewClass and then store the data into ArrayList and return the ArrayList.
    It should look like
    {code:java}
    package ris;
    import java.sql.*;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    public class  NewClass{
        public static ArrayList getNames(){
            Connection con = null;
            ResultSet rs=null;
            Statement smt=null;
            ArrayList nameList = new ArrayList();
            try{
                Class.forName("com.mysql.jdbc.Driver").newInstance();
                con=DriverManager.getConnection("jdbc:mysql:///net","root", "anthony111");
                smt=con.createStatement();
               rs= smt.executeQuery("SELECT * FROM emp");
               while(rs.next()){
                nameList.add(rs.getString("Name"));
               return nameList;
                }catch( Exception e){
                    String msg="Exception:"+e.getMessage();
                   </code><code class="jive-code jive-java"><font>return nameList;</code><code class="jive-code jive-java">
                }finally {
          try {
            if(con != null)
              con.close();
          } catch(SQLException e) {}
          </code><code>return nameList;</code>
    <code class="jive-code jive-java">    }

  • Problem importing classes and beans

    Hey there. Im having one major fustrating problem! When I code supporting classes and beans for my JSPs I get a code 500 internal server error when trying to import (via <%@ page import="class" %> and <jsp:useBean/>) Im storing my classes and beans in the WEB-INF folder and the calling JSPs are located in /ROOT/tests/8/jsp.jsp. Im using the following to import a class or bean:
    <%@ import="aClass" %>
    Seen as tho its in the WEB-INF folder I won't have to explicitly refer to where the class is located, just the class name.
    I never had this problem when I was using my hosting service. Its only on my localhost server in which I get the Internal Server error.
    Help appreciated, thx.
    PS: Im quite new to JSP/Java Servlet.

    import (via <%@ page import="class" %> and
    <jsp:useBean/>) Im storing my classes and beans in the
    WEB-INF folder try put your class file in WEB-INF/classes.
    or first put bean in the package, like WEB-INF/classes/packagename/beanclass
    in jsp page:
    <jsp:useBean id="Mybean" class="packagename.beanclass" scope="request" />
    Question: is /ROOT a context entry in your server.xml?
    Which JSP Container (version) you use? Maybe your localhost server's set up is different with your hosting.

  • Accessing java class and methods within JSP

    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 = "Whatever.class" %>
    Any help would be greatly appreciated.
    Kal.

    Hi.. Thanks for ur reply.
    I am actually having a problem with the import statement. So the part where you have mypackage.Myclass, it is not working for me.
    I am using Sun Forte.. and the directory is myprojects/test/Classes/MyClass.java
    so how would the import statement look like?
    Thanks
    Kal.
    Using directive for import statements:
    <%@ page
    import="java.util.*,java.sql.*,mypackage.MyClass" %>
    Then use scriptlet:
    <%! MyClass c= new MyClass(); %>
    <%! private void method() {...} %>
    <%= c.getxxx() %>
    ...and so on

  • Jsp Page session vaiable to java class and vise versa

    Hi to all,
    I am new to jsp, i have to programs, one jsp page and another java class. in jsp page i get the user data from html form and put the id in session. here i have to call the session vaiable to my java class where it (variable)initialize a file name.
    and same i have to call the java class to jsp page which insert statements to sql server,
    Please Help Me.

    //My Java Class file
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.SQLException;
    import javax.servlet.http.HttpSession;
    import java.sql.Statement;
    public class StuInfo extends Object {
    //main method begins execution of Java application
    public static void main (String args[]){
    String StuFile = "C://"+iD+".txt"; // Here i have to get the session varaible.(ID)
    try {
    In my jsp Page i initilized session as
    session.setAttribute("ID",StuId);
    I am not able to understand where i have to declear the HTTPSession#getAttribute("ID");

  • Classes and JSPs in Tomcat-4.1.24

    Where to put the class files and how to call them in the jsps in Tomcat-4.1.24.
    <br>In Tomcat-3.2.4 I used to put them in WEB-INF/classes and call them. The same jsp's working in Tomcat-3.x are not working in 4.1.24 version. Any idea???
    Thanx in advance

    Apparently tomcat4.1 requires all class files to be in a package so class files that you just had in WEB-INF/classes need to be re-compiled into packages.
    Then you will need to import these classes into your jsp with a
    <%@ page import= ..../> statement

  • Importing classes, and what happened to my libraries in Flash?

    Good evening ladies and gents.
    How do I import existing classes from an old CS3 Flash project.  I have a few classes that I'd really rather not rewrite but when I attempt an import the .as files Flash Builder requires that I build a new project.  Additionally, since I downloaded the new builder, I haven't been able to import the fl.controls.* in my Flash applications.  It's fine for now because I'm ramping up on Flash Builder and need to work in the new dev environment for awhile but in 28 days, I can't really have my Flash software in limbo.  Any insight?  Also in the same thread as the first inquiry, I downloaded the google Flex components from the intro to FB4 links, a quick explanation on incorporating the new componenets would help too since I can't seem to recapture the page where I found the link.  Thanks.

    Hi James,
    I may be misunderstanding your situation but I think you need to create at least one new project in Flash Builder in order to use your AS classes.  After created your porject, you can either import your AS classes using Import -> General -> File System into your project, or set a class path to your classes by going Project properites -> Build Path then addind a parent folder of your classes to Source path.
    Thank you,
    -Yukari
    Flash Builder QE

  • Importing classes and performance

    Is there any difference in performance between importing all the package and importing only the needed classes. I am doing an applet project and as it first must download the classes I wonder if it may be faster to import just the needed classes instead of all of the package.

    Is there any difference in performance between
    importing all the package and importing only the
    needed classes. I am doing an applet project and as
    it first must download the classes I wonder if it may
    be faster to import just the needed classes instead
    of all of the package.Importing has zero effect at runtime. It does NOT cause any classes to be "downloaded" or loaded or anything like that. If you import everything.* or specific classes or nothing at all, the generated byte code will be identical, and the VM will do exactly the same thing.
    Importing only matters at compile time. It just lets you use, for example, List instead of java.util.List, and the compiler then figures out what you mean by List.
    Having said that, it's generally considered better form to import specific classes. This makes it easier for somebody reading your code later (including you) to see which classes came from where.

  • JSP, c:forEach, and import / include(s)

    To any,
    I'm having a bit of a problem. I'm currently working on a webapp which basically translates information in an XML file to a neat webpage, using Spring MVC / JSP / JSTL / the works.
    There's several items in the XML file that are of the same format, which as such use the exact same bit of HTML to represent. So, I figured, let's do it like so and so:
    <c:forEach items="${plugin.executions.execution}" var="execution">
         <jsp:include url="execution.jsp"/>
    </c:forEach> Buut this doesn't work, most likely because execution.jsp is parsed / compiled not at runtime, but at compile time (or whatever), leading to an error (which I can't see by the way) because the 'execution' variable isn't present in execution.jsp.
    Note that I'm not getting any errors (at least, not in the console using Maven, the jetty:run command), just a blank screen with nothing in there.
    What I'm looking for is a solution to this. Basically, I'm looking for an include statement that chucks the html / jsp found in execution.jsp into the forEach loop, then compiles and displays it.
    I've tried <jsp:include>, <c:import>, <%@ page import=""%>, but none of the three works. I've asked for an alternative, but those include creating my own tag library (although I don't think that'll work) or switching to an entirely different view framework (like Wiicket). Seeing that it'll take days to convert the application to a different framework (including AppFuse, I think, which is the app I'm building on top of), I'd rather not.
    The other alternative is copy / pasting a load, which will work (I know it'll work), but making a change will result in making half a dozen changes, one for each copy / paste job. I'd prefer a solution like this.
    Help me plox :(.

    On second thought, nevermind. Re-asked my colleague, and he pointed out the use of tag files
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPTags5.html
    Which works excellently, imho.

  • Using a single connection for jsp, servlets and classes

    Hi! I'm building a web site that uses JSP, Servlets and some classes. I use database access in all my pages. I want to open a connection and use it for all the pages while the user is in my site, so I don't need to open a connection with every new jsp or servlet page. My software must be capable of connection with various databases, like SQLServer, Oracle, Informix, etc... so the solution must not be database (or OS or web server) dependant.
    Can you help me with this? Some ideas, links, tips? I'll REALLY appreciate your help.
    Regards,
    Raul Medina

    use an initialiation servlet with pooled connection which can be accessed as sesssion object.
    Abrar

  • Help importing a class and initializing it

    Hi guys...
    I have a (what I think is) a little problem but after being the whole night awake I can´t think anymore...
    I have a button which sends you to frame 10 and in frame 10 I suppose to intialize the class I imported:
    import Payment;
    getpremium.addEventListener(MouseEvent.CLICK, PI);
    function PI(e:MouseEvent):void {
         gotoAndStop(10);
    Now in frame 10 the only thing I have is:
    Payment();
    and the class (how it starts) is:
    package
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.IOErrorEvent;
        import flash.events.MouseEvent;
        import flash.net.URLLoader;
        import flash.net.URLRequest;
        import flash.text.TextField;
        import flash.text.TextFormat;  //etc
    public class Payment extends Sprite
            private var paymentSystem:PaymentSystem;
            private var buyList:List;
            private var loader:URLLoader;
            private var pastPurchases:Array = [];
            private var alltextformats:TextFormat = new TextFormat();
            public function Payment()
                paymentSystem = new PaymentSystem(); //etc
    What do I suposse to write down on frame 10 for the class to be initialized?
    Thanks!!!

    Normally what you need to do is instantiate a Payment object...
    import Payment;
    var payment:Payment = new Payment();

  • IMPDP to import  JAVA CLASS  and JAVA SOURCE from .DMP file

    hi,
    I have a schema X, In that schema some of the *"JAVA CLASS" and "JAVA SOURCE"* objects are missing ..
    The procedures ,functions..etc objects were updated at X schema..
    I have 1 dmp file of Y schema , containing the missing "JAVA CLASS" and "JAVA SOURCE" s.. Can I import the the same to the schema X using IMPDP
    i tried using INCLUDE clause but it is not working
    eg:
    impdp john1/john1@me11g22 directory=datadump dumpfile=DEVF2WAR.DMP remap_schema=devf2war:john INCLUDE="JAVA CLASS","JAVA CLASS"but error..
    ORA-39001: invalid argument value
    ORA-39041: Filter  "INCLUDE" either identifies all object types or no object types.regards,
    jp

    Hello,
    You should type JAVA_CLASS and JAVA_SOURCE (use underscore instead of space).
    impdp john1/john1@me11g22 directory=datadump dumpfile=DEVF2WAR.DMP remap_schema=devf2war:john INCLUDE="JAVA_CLASS","JAVA_CLASS"Best Regards,
    Gokhan Atil
    If this question is answered, please mark appropriate posts as correct/helpful and the thread as closed. Thanks

Maybe you are looking for

  • How to make SWF in GoLive show in IE in v5, 6 or 8

    I would like to get a Flash file to work in Internet Explorer v5, 6 and 8. I am creating a site and the flash clip won't play in these browsers (but will in IE v7). Does anyone have any ides? Thanks.

  • Inco Terms in Vendor Master &Pur info Record

    Hi all I am maintaining the Incoterms in Vendor Master. But if i give the code (Inco term - Part1, again the system is asking to enter the Description Incoterm - Part2). Aslo if i am maintaining the Purchase info record, for the same vendor and Mater

  • Can I Use Swing Components in a JSP Page

    Hi, Can I use Swing Componnents in a JSP Page.If so,Can anybody provide with a sample code. Thanks.

  • Photoshop Elements 9 Organizer hat ein Problem festgestellt und muss beendet werden.

    Mit dieser Popup Meldung verabschiedet sich mein neu installiertes Pse9. Eine Neuinstallation half nicht weiter. Weitere Informationen zum Fehler: AppName: photoshopelementsorganizer.exe AppVer: 9.0.3.0 ModName: pclempegbox.ax ModVer: 4.0.8.0 Offset:

  • Exception when uploading HTM file

    Hi, A quick question regarding the KM repositories. I have a link to a subfolder in the etc directory from the documents folder. This folder contains some standard htm files. If I download one of the files, modify it and upload it again I'm asked wet