Understanding Java Class Accessibility

I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser? If the latter, what determines whether or not the typical computer will have the TreeMap class available? Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies? Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?

"I don't understand what makes a Java library class accessible by a Java applet. If an applet has an import statement that imports, say, java.util.TreeMap, then when a web browser accesses a web page containing that applet, does it download the Java code for the TreeMap class at that time, and if so, does that mean that you have to package the TreeMap class as part of your applet class code somehow? "
No.
"Or, must the TreeMap class be installed as part of the Java virtual machine on the computer that is running the browser?"
Yes
"If the latter, what determines whether or not the typical computer will have the TreeMap class available?"
The version of the Java Runtime environment/Plug-in installled on the PC
"Is the TreeMap class available on a PC running Windows XP, using the Java virtual machine that Microsoft supplies?"
No which why some people don't use the newer Java classes or Swing when they write applets.
"Where can I read about this sort of thing? How can I determine what classes I can safely use if I want my applet to run on both Windows and Macs?"
http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/using_tags.html

Similar Messages

  • Java class access modifiers

    Why java class cannot have private and protected access modifiers?

    class X {
      private class y {}
    }should compile just fine. A top-level private class makes no sense because you wouldn't be able to see it. As for protected, I don't know.

  • Suggest tutorial or article for understanding Java Class Loaders

    I want to learn about the Java Class Loaders, from basics to writing custom Class Loaders. Please suggest good material for the same.

    [http://www.javalobby.org/java/forums/t18345.html]
    [http://java.sun.com/developer/onlineTraining/Security/Fundamentals/magercises/ClassLoader/help.html]
    [http://publib.boulder.ibm.com/infocenter/javasdk/v1r4m2/index.jsp?topic=/com.ibm.java.doc.diagnostics.142/html/id1100.html]
    [http://onjava.com/pub/a/onjava/2005/01/26/classloading.html]
    [http://java.sun.com/developer/technicalArticles/Networking/classloaders/]
    [http://www.informit.com/articles/article.aspx?p=1187967]
    This should keep you busy.
    Usually learning about classloader's is coupled with learning to develop with Java's security features and therefore I think most Java security books dedicate a chapter for it.

  • Help me which JNDIFactory to use to access EJB from a java class of JAR

    I am confused in understanding the different JNDI factories
    RMIInitialContextFactory, ApplicationInitialContextFactory and ApplicationClientInitialContextFactory
    And the different namespaces like global, container local and component local.
    Especially is there any relationship between the JNDI factories and the namespaces?
    Or are they related to the deployment descriptors.
    Because in application specific deployment descriptors (orion-ejb-jar.xml), we just map the JNDI location with the object (or its reference from ejb-jar.xml). We dont specify it can be accessed from this factory or that.
    Shall we access an EJB from using any JNDI factory?
    Specifically, I am stuck with what Factory to use to access an EJB from a Java class in a library (jar). The JAR is packaged with the EAR which contains the EJB Jar that I am trying to access.
    THANK YOU

    Ed,
    As Robin said, I think you need code similar to this:
    Context c = new InitialContext();
    Object o = c.lookup("java:comp/env/Name");where Name is the name of your EJB as it appears in the "ejb-jar.xml"
    deployment descriptor XML file.
    Good Luck,
    Avi.

  • Java class bean can not access to DB in JSP file

    Hi, I wrote a java class bean in order to access to MySql database ,and this bean is used in a JSP file,so that the bean can query from DB and then display the queried information on the JSP file,but it can not work correctly,the following is the source code and error message popup by the system,
    does anybody has experience in solving thus question,Please reply ,Thank you for your help.
    %@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ page import = "java.sql.*" %>
    <jsp:useBean id="conn" scope="page" class="news.conn"/>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>1</title>
    <style>
    <!--
    A:link {
         COLOR: #993399
    .s {
         FONT-SIZE: 13px; LINE-HEIGHT: 170%; FONT-FAMILY: "utf-8"
    -->
    </style>
    </head>
    <body>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
    <tr>
    <td width="100%">
    <img border="0" src="images/ruanjian.jpg" width="770" height="154"></td>
    </tr>
    <tr>
    <td width="100%">@</td>
    </tr>
    </table>
    <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber2">
    <tr>
    <td width="13%">@</td>
    <td width="87%">
    <img border="0" src="images/mid-rdxw2.gif" width="101" height="18"><p>
    <%
              ResultSet rs,rsNest;
    String strSql=null;
    strSql = "select * from news where TYPE=1";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt(id")%">"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>
    <img border="0" src="images/mid-hyxw2.gif" width="94" height="19"></p>
    <%
    strSql="select * from news where TYPE=2";     
              rs = conn.executeQuery(strSql);
              while (rs.next()){
    %>
    <span class="s"> <a href="newsContent.jsp?newsId=<%=rs.getInt("id")%>"><%=rs.getString("Title")%></a><br>
    <%
    %>
    <p>@</td>
    </tr>
    </table>
    <p align="center">Study Online</p>
    <p align="center">@</p>
    </body>
    </html>
    Error message:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Exception in JSP: /newsMain.jsp:47
    44: strSql = "select * from news where TYPE=1";     
    45:           rs = conn.executeQuery(strSql);
    46:           
    47:           while (rs.next()){
    48:
    49: %>
    50:
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:373)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    root cause
    java.lang.NullPointerException
         org.apache.jsp.newsMain_jsp._jspService(newsMain_jsp.java:98)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.27 l</a>

    nogoodatcoding wrote:
    Tolls wrote:
    Is that Jasper Exception telling us where the problem is in the jsp, though?
    If it is, then "rs" is null in the call rs.next()...which means conn.executeQuery() is returning null. Which means that whatever class conn is (news.conn?) has a problem maybe?That's possible. Though, it may just be the case that the 'conn' object itself is null! That line is the first place where it's being used and there are no checks that I can see...we'll have to wait for the OP to investigate and reply I guess.That's what I originally thought, then I noticed it was saying line 47, which is the rs.next() line. Assuming Jasper is correct in its choice of line, then it's the rs that's null. Which means the conn is doing strange things.
    Edit: Now that I think about it, going by the previous thread the OP posted, I'm wondering whether news.conn class is their attempt to move the JDBC stuff out of the JSP page, and it's grabbing the "real" connection (java.sql.Connection) and getting the result set and returning it...or getting something wrong and returning null.
    Edited by: Tolls on 11-Jun-2009 12:24

  • How to access variables declared in java class file from jsp

    i have a java package which reads values from property file. i have imported the package.classname in jsp file and also i have created an object for the class file like
    classname object=new classname();
    now iam able to access only the methods defined in the class but not the variables. i have defined connection properties in class file.
    in jsp i need to use
    statement=con.createstatement(); but it shows variable not declared.
    con is declared in java class file.
    how to access the variables?
    thanks

    here is the code
    * testbean.java
    * Created on October 31, 2006, 12:14 PM
    package property;
    import java.beans.*;
    import java.io.Serializable;
    public class testbean extends Object implements Serializable {
    public String sampleProperty="test2";
        public String getSampleProperty() {
            return sampleProperty;
    }jsp file
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ page import="java.sql.*,java.util.*"%>
    <html>
    <head>
    <title>Schedule Details</title>
    </head>
    <jsp:useBean id="ConProp" class="property.testbean"/>
    <body>
    Messge is : <jsp:getProperty name="msg" property="sampleProperty"/>
    <%
      out.println(ConProp.sampleProperty);
    %>
    </body>
    </html>out.println(ConProp.sampleProperty) prints null value.
    is this the right procedure to access bean variables
    thanks

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • How to get access to PageContext in a java class (.java file)?

    Hi all,
    I am trying to get access to PageContext from inside a java class, and it doesn't seem to work.
    I could get the PageContext from a jsp page, at the object instantiation, through the constructor, but my class is not called by a jsp page.
    Any ideas?
    Thanks,
    Paul

    Basically I do not need to change any attributes from pageContext. However I need the pageContext object because I am using a third party component that is initialized with the pageContext .
    I cannot change the implementation of that component: it is a black box to me, I simply need the pageContext in my java class that uses the component.
    Any thoughts based on this clarification?
    Thanks,
    Paul

  • PI 7.1 Access to Dynamic Configuration through Java Class

    My Current scenario involves IDCO -> FILE communications in PI 7.1 using XSL where the file name is dynamic.
    I have attempted calling a Java Class from XSL with the use SAPXMLTOOL kit option set in the adaptor and it works but I need to be able to call the transform method
    public void transform(TransformationInput arg0, TransformationOutput arg1)
    from XSL so I can access the message and update the File Name via Dynamic Configuration.
    Whilst I can call a static class with in the object I can not call transform with the correct arguments (arg0, arg1). I need access to arg0 (payload) to set/figure out the filename. I can calculate the filename in XSL and pass it to the Java but in a static method it is useless as it need to access the arg0 which is a object and obviously non-static context.
    Is this possible ? How do I get access to Dynamic Configuration from XSL through Java in 7.1 ?
    I have successfully called a static method but that is no help.
    Thanks in advance.

    Suraj,
       Unfortunately you link isnt operational but thankyou anyway, I have managed to call as Java class as per my original post, but a static method does not allow me to get a handle to the Dynamic Configuration Variables in the message.
    It seems importing the 7.0 LIBS may be an option and Im not entirely sure I have that option.
    It certainly isnt possible to use the JDK5 XML implementation to even call a static method on an Java OBJ from XSL (obviously the USE SAPXMLTOOLKIT option is there for a reason).
    I think and again I could be wrong but direct access via XSLT..
    LINK:http://help.sap.com/saphelp_nwpi71/helpdata/EN/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    Is what Im looking for, I shall report back success or failure but the doco seems to fit the bill. Im not sure why I wanted to instatiate a sperate Java class when it can all exist in the XSLT.

  • Accessing Java Resource in a Java class

    How does one go about accessing a java resource object from a java class loaded into the database?
    I created a.properties file and loaded it using loadjava.
    Next I wrote a class in which I try to load the resource:
    import java.io.*;
    import java.util.*;
    public class C {
    public static void load() throws Exception {
    Properties p = new Properties();
    p.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("a.properties"));
    I then published method load as procedure p.
    When I execute p, I get the following error:
    SQL> exec p
    java.lang.NullPointerException
    at C.load(C.java:5)
    BEGIN p; END;
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NullPointerException
    ORA-06512: at "QSI.P", line 0
    ORA-06512: at line 1
    Thanks
    Suresh

    Never mind. I resolved this using a ResourceBundle, thanks to another posting on this forum. I must say, the oracle documentation for this feature is scant and erroneous.
    How does one go about accessing a java resource object from a java class loaded into the database?
    I created a.properties file and loaded it using loadjava.
    Next I wrote a class in which I try to load the resource:
    import java.io.*;
    import java.util.*;
    public class C {
    public static void load() throws Exception {
    Properties p = new Properties();
    p.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("a.properties"));
    I then published method load as procedure p.
    When I execute p, I get the following error:
    SQL> exec p
    java.lang.NullPointerException
    at C.load(C.java:5)
    BEGIN p; END;
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.lang.NullPointerException
    ORA-06512: at "QSI.P", line 0
    ORA-06512: at line 1
    Thanks
    Suresh

  • Access DataControls methods in a java class

    Hi All,
    Jdeveloper Version 11.1.5
    I have created DataControls for SessionFacade web service.
    Inside the datacontrol there is a method getAllDepartments() which have a Return type which includes DaertmentId,DepartmentName,....
    I want to know how can i access this method inside a Java Class and create a list of only departmentId.

    You would need to add the method in the data control as a method action in your pageDef.
    After that, you could access the method as mentioned above.
    Thanks,
    Navaneeth

  • Custom Fault Policy java class is not able to access mediator.jar file

    Hi,
    I am trying to implement the custom java class for mediator fault handling. However when this class is invoked its not able to access the "oracle.tip.mediator.common.error.recovery.MediatorRecoveryContext" class during run time (which exists in mediator.jar). However its able to access all the other imported class files which exists in other library files.
    Do we need to add mediator.jar to the weblogic classpath manually or should we place that jar file in some location in the server ?? Its currently residing in the path -- /app/oracle/product/soastg/11.1.0/SOA/soa/modules/oracle.soa.mediator_11.1.1/mediator.jar. I tried to copy the same jar into domain lib and admin lib path but there was no luck.
    Any input on this will be helpful.
    Thanks,
    Ramesh

    Hi Ramesh,
    Try out the following
    1) Copy mediator.jar from SOA_HOME>/soa/modules/oracle.soa.mediator_11.1.1 to <MW_HOME>//soa/modules/oracle.soa.ext_11.1.1/classes
    2) Goto <MW_HOME>//soa/modules/oracle.soa.ext_11.1.1/classes and run the following command:
    a. jar -xvf mediator.jar
    3) Now remove the jar file, i.e., mediator.jar from classes folder.
    4) Restart the server.
    Regards,
    Srijith

  • Accessing java class in JSP on Tomcat 5.5 server

    Just i want to use a java class in JSP.
    Explanation in following steps :
    a. MY JSP Code - SimpleBean.jsp
    b. My Java file - test.java
    c. Path ( Root, jdk, jre , myfiles-test.java, SimpleBean.jsp )
    d. Environment Variables
    e. Error Message faced
    Now Brief explanation.
    a. MY JSP Code :
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*,test" errorPage="" %>
    <td>      
    <%! test obj = new test();
    obj.setAge(32); %>
    <%= obj.getAge(); %>
    </td>
    b. My Java file - test.java
    package test;
    class test
    private int age;
    public int getAge()
         return age;
         public void setAge(int intage)
              this.age = intage;
    c. Path ( Root, jdk, jre , myfiles-test.java, SimpleBean.jsp )
    Tomcat Root : c:\Program Files\apache\tomcat5.5\webapps\ROOT
    jdk : C:\Program Files\Java\jdk1.5.0\bin;
    jre : C:\Program Files\Java\jre1.5.0\bin;
    test.java : c:\Program Files\apache\tomcat5.5\webapps\ROOT\NRMS\test\test.java
    SimpleBean.jsp : c:\Program Files\apache\tomcat5.5\webapps\ROOT\NRMS\test\SimpleBean.jps
    d. Environment Variables :
    PATH :
    C:\Program Files\Java\jdk1.5.0\bin; C:\Program Files\Java\jre1.5.0\bin;
    CLASSPATH :
    .;C:\Program Files\Java\jre1.5.0\bin;
    e. Error Message Faced : ( on accessing url http://localhost:8080/NRMS/SimpleBean.jsp )
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    The import test cannot be resolved
    An error occurred at line: 26 in the jsp file: /NRMS/test/SimpleBean.jsp
    Generated servlet error:
    test cannot be resolved (or is not a valid type) for the field SimpleBean_jsp.obj
    An error occurred at line: 26 in the jsp file: /NRMS/test/SimpleBean.jsp
    Generated servlet error:
    test cannot be resolved or is not a type
    An error occurred at line: 26 in the jsp file: /NRMS/test/SimpleBean.jsp
    Generated servlet error:
    Syntax error on token(s), misplaced construct(s)
    An error occurred at line: 26 in the jsp file: /NRMS/test/SimpleBean.jsp
    Generated servlet error:
    Syntax error on token "32", delete this token
    An error occurred at line: 28 in the jsp file: /NRMS/test/SimpleBean.jsp
    Generated servlet error:
    Syntax error on token ";", delete this token
         org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
         org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:389)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:556)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:296)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.4 logs.
    Apache Tomcat/5.5.4
    Please explain where i am doing the mistake.
    Thanks in advance.
    Regards,
    Lax.

    >
    <%@ page contentType="text/html; charset=iso-8859-1"
    language="java" import="java.sql.*,test" errorPage=""
    %>Your class is test.test.The compiler wouldnt know what test is from your import.
    Change import as
    java.sql.*,test.test
    <%! test obj = new test();
    obj.setAge(32); %>The symbol '!' ?

  • Accessing a java class method from the jsp page.

    Hi im a beginner with jsp and im trying to find a way to access a method of my java class file in jsp page. After searching through the forums i tried to use the usebean tag. Im using apache to host the jsp file.Below is an excerpt of my code and the error message i got. What am i doing wrong? anyone know?
    <%@ page language="java" %>
    <jsp:useBean id="movies" class="movie.Movie" />
    <jsp:setProperty name="movies" property="*"/>
    <%
    movies.getStart("file:///C:/Video/Applications2/sun.mpg");
    response.setContentType("text/xml");
    %>
    exception
    org.apache.jasper.JasperException: Exception in JSP: /View.jsp:7
    4: <jsp:setProperty name="movies" property="*"/>
    5: <%
    6:
    7: movies.getStart("file:///C:/Video/Applications2/sun.mpg");
    8: response.setContentType("text/xml");
    9: %>
    Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    root cause
    javax.servlet.ServletException: javax/media/ControllerListener

    Hi thanks for responding. Ok i did look through and it was opening some gui. I still need the program to do server side processes so cant use an applet.but i dont need the gui so i revised it and removed the gui. also im using a servlet to call the class now yet i still have the same error. Any ideas?
    Below is the vid2jpg code minus the gui.
    import java.io.*;
    import java.awt.*;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    import java.awt.image.*;
    import javax.imageio.*;
    public class vid2jpg implements ControllerListener
         Processor p;
         Object waitObj = new Object();
         boolean stateOK = true;
         DataSourceHandler handler;
    int imgWidth;int imgHeight;
         Image outputImage;
         String sep = System.getProperty("file.separator");
         int[] outvid;
         int startFr = 1;int endFr = 1000;int countFr = 0;
         boolean sunjava=true;
         * Static main method
         public static void main(String[] args)
              if(args.length == 0)
                   System.out.println("No media address.");
                   new vid2jpg("file:///C:/Video/applications2/sun.mpg");     // or alternative "vfw://0" if webcam
              else
                   String path = args[0].trim();
                   System.out.println(path);
                   new vid2jpg(path);
         * Constructor
         public vid2jpg(String path)
              MediaLocator ml;String args = path;
              if((ml = new MediaLocator(args)) == null)
                   System.out.println("Cannot build media locator from: " + args);
              if(!open(ml))
                   System.out.println("Failed to open media source");
         * Given a MediaLocator, create a processor and start
         private boolean open(MediaLocator ml)
              System.out.println("Create processor for: " + ml);
              try
                   p = Manager.createProcessor(ml);
              catch (Exception e)
                   System.out.println("Failed to create a processor from the given media source: " + e);
                   return false;
              p.addControllerListener(this);
              // Put the Processor into configured state.
              p.configure();
              if(!waitForState(p.Configured))
                   System.out.println("Failed to configure the processor.");
                   return false;
              // Get the raw output from the Processor.
              p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW));
              TrackControl tc[] = p.getTrackControls();
              if(tc == null)
                   System.out.println("Failed to obtain track controls from the processor.");
                   return false;
              TrackControl videoTrack = null;
              for(int i = 0; i < tc.length; i++)
                   if(tc.getFormat() instanceof VideoFormat)
                        tc[i].setFormat(new RGBFormat(null, -1, Format.byteArray, -1.0F, 24, 3, 2, 1));
                        videoTrack = tc[i];
                   else
                   tc[i].setEnabled(false);
              if(videoTrack == null)
                   System.out.println("The input media does not contain a video track.");
                   return false;
              System.out.println("Video format: " + videoTrack.getFormat());
              p.realize();
              if(!waitForState(p.Realized))
                   System.out.println("Failed to realize the processor.");
                   return false;
              // Get the output DataSource from the processor and set it to the DataSourceHandler.
              DataSource ods = p.getDataOutput();
              handler = new DataSourceHandler();
              try
                   handler.setSource(ods);     // also determines image size
              catch(IncompatibleSourceException e)
                   System.out.println("Cannot handle the output DataSource from the processor: " + ods);
                   return false;
         //     setLayout(new FlowLayout(FlowLayout.LEFT));
    //          currPanel = new imgPanel(new Dimension(imgWidth,imgHeight));
         //     add(currPanel);
         //     pack();
              //setLocation(100,100);
         //     setVisible(true);
              handler.start();
              // Prefetch the processor.
              p.prefetch();
              if(!waitForState(p.Prefetched))
                   System.out.println("Failed to prefetch the processor.");
                   return false;
              // Start the processor
              //p.setStopTime(new Time(20.00));
              p.start();
              return true;
         * Sets image size
         private void imageProfile(VideoFormat vidFormat)
              System.out.println("Push Format "+vidFormat);
              Dimension d = (vidFormat).getSize();
              System.out.println("Video frame size: "+ d.width+"x"+d.height);
              imgWidth=d.width;
              imgHeight=d.height;
         * Called on each new frame buffer
         int nextframetime = 0;
    private void useFrameData(Buffer inBuffer)
    try
    if(inBuffer.getData()!=null) // vfw://0 can deliver nulls
    if(sunjava) // and with import javax.imageio.*;
    int frametimesecs = (int)(inBuffer.getTimeStamp()/1000000000);
    if(frametimesecs%10 == 0 && frametimesecs==nextframetime)
    nextframetime+=10;
    BufferedImage bi = new BufferedImage(outputImage.getWidth(null), outputImage.getHeight(null), BufferedImage.TYPE_INT_RGB);
    Graphics g = bi.getGraphics();
    ImageIO.write(bi, "png", new File("images"+sep+"image_"+(inBuffer.getTimeStamp()/1000000000)+".png"));
    catch(Exception e){}
         * Tidy on finish
         public void tidyClose()
              handler.close();
              p.close();
         * Block until the processor has transitioned to the given state
         private boolean waitForState(int state)
              synchronized(waitObj)
                   try
                        while(p.getState() < state && stateOK)
                        waitObj.wait();
                   catch (Exception e)
              return stateOK;
         * Controller Listener.
         public void controllerUpdate(ControllerEvent evt)
              if(evt instanceof ConfigureCompleteEvent ||     evt instanceof RealizeCompleteEvent || evt instanceof PrefetchCompleteEvent)
                   synchronized(waitObj)
                        stateOK = true;
                        waitObj.notifyAll();
              else
              if(evt instanceof ResourceUnavailableEvent)
                   synchronized(waitObj)
                        stateOK = false;
                        waitObj.notifyAll();
              else
              if(evt instanceof EndOfMediaEvent || evt instanceof StopAtTimeEvent)
                   tidyClose();
         * Inner classes
         * A DataSourceHandler class to read from a DataSource and displays
         * information of each frame of data received.
         class DataSourceHandler implements BufferTransferHandler
              DataSource source;
              PullBufferStream pullStrms[] = null;
              PushBufferStream pushStrms[] = null;
              Buffer readBuffer;
              * Sets the media source this MediaHandler should use to obtain content.
              private void setSource(DataSource source) throws IncompatibleSourceException
                   // Different types of DataSources need to handled differently.
                   if(source instanceof PushBufferDataSource)
                        pushStrms = ((PushBufferDataSource) source).getStreams();
                        // Set the transfer handler to receive pushed data from the push DataSource.
                        pushStrms[0].setTransferHandler(this);
                        // Set image size
                        imageProfile((VideoFormat)pushStrms[0].getFormat());
                   else
                   if(source instanceof PullBufferDataSource)
                        System.out.println("PullBufferDataSource!");
                        // This handler only handles push buffer datasource.
                        throw new IncompatibleSourceException();
                   this.source = source;
                   readBuffer = new Buffer();
              * This will get called when there's data pushed from the PushBufferDataSource.
              public void transferData(PushBufferStream stream)
                   try
                        stream.read(readBuffer);
                   catch(Exception e)
                        System.out.println(e);
                        return;
                   // Just in case contents of data object changed by some other thread
                   Buffer inBuffer = (Buffer)(readBuffer.clone());
                   // Check for end of stream
                   if(readBuffer.isEOM())
                        System.out.println("End of stream");
                        return;
                   // Do useful stuff or wait
                   useFrameData(inBuffer);
              public void start()
                   try{source.start();}catch(Exception e){System.out.println(e);}
              public void stop()
                   try{source.stop();}catch(Exception e){System.out.println(e);}
              public void close(){stop();}
              public Object[] getControls()
                   return new Object[0];
              public Object getControl(String name)
                   return null;
    below is the servlet code.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    public class ShowMovie extends HttpServlet {
    String rootURL="http://127.0.0.1:8080/Video/";
    public void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
         //String movie=request.getParameter("movie");
         String movie ="son";
         getStart(movie);
              response.sendRedirect(rootURL+"View.jsp");
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    processRequest(request, response);
         public void getStart(String url){
              new vid2jpg(url);
    this is the error from the server. Im using tomkat 5
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoClassDefFoundError: javax/media/ControllerListener
         java.lang.ClassLoader.defineClass1(Native Method)
         java.lang.ClassLoader.defineClass(Unknown Source)
         java.security.SecureClassLoader.defineClass(Unknown Source)
         org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1812)
         org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:866)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1319)
         org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
         java.lang.ClassLoader.loadClassInternal(Unknown Source)
         ShowMovie.getStart(ShowMovie.java:31)
         ShowMovie.processRequest(ShowMovie.java:14)
         ShowMovie.doGet(ShowMovie.java:22)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.17 logs.

  • Accessing java classes from javascript

    Hi,
    I have the following javascript function
    function testjava {   
        var myString = new java.lang.String("Hello world"); // line 1
        alert("len:"+myString.length()); // line 2
    }It gives me a error at line 1 saying "'java' is undefined" in IE browser 5.5 sp2. But, both the lines execute correctly in netscape 6.
    Can someone please help..
    Thanks,
    Vijay.

    It seems that IE 5.5 doesn't support accessing java classes in JavaScript, so try to install IE 6 to see if it works or maybe, you doesn't have installed propertly support for JVM in IE.

Maybe you are looking for

  • Images will not display in website please help

    im using dreamweaver cs5. My custom images created in photoshop and saved as jpg will not upload into my website. i get a white box with a red x on the corner. I do have my images  in my images folder in my loca files and in my local image folder. It

  • Kodak hero 5.1 not finding my laptop to scan to

    Hi my kodak hero 5.1 is printing from my new lap top but when I go to scan it is only giving me the option to scan to a USB-connected computer - usually if I press the > key it gave me the option of scanning to my laptop (it was already on there)  pl

  • Performing Quick Match Programmatically

    Hi Experts, I 've a requirement to perform quick match of AP Invoices with POs programmatically. Here is the scenario: 1) Invoice is imported through an external source 2) Invoice has only one line (equal to the sum of "ITEM" type line amounts on the

  • A general programation question

    I have a ProductQuantity with a product and a quantity fields. According to good programation tecniques, should I use it just like that or should I put a getProduct, and a getQuantity methods, and make product and quantity private? Thanks. class Prod

  • NVIDIA Quadro K1100M / Intel HD Graphics 4600

    I am currently on Technical Preview build 9926 and the driver for the K1100M is not functioning properly. I have tried to update it though still am running into issues with it being recognized.  EDIT: Just wanted to update this - I have now gotten th