Loading Java Class File in JSP page

I'm trying to load a java class file from a jsp page.
(e.g. MyFile.java <-- Source "MyFile.class<--Class file of MyFile.java")
jsp page
<%@ include file = "MyFile.class" %>
<HTML> // HTML Tags are here
MyFile.java
A normal java source file that has "public static void main" in it.
My jsp page can display it's contents, 'except' for showing e.g. "1235%%215648%%public%%$$@##" through out the page...
My guess is that it can't display my java class file..
Can anyone please help me solve this problem of mine ?
Thanks in advance : )
Yours Sincerely,
RainbowEnergies

This is my JSP file.
<HTML>
<HEAD>
<TITLE>Activity Games</TITLE>
</HEAD>
<%
String name = "";
String id = "";
name = session.getAttribute("name").toString();
session.setAttribute("name",name);
id = session.getAttribute("id").toString();
session.setAttribute("id",id);
%>
<BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
<H3><%=name%>, you have enter Activity Games</H3>
<%@ page import="Games.Lufia.*" %>
<%Lufia lufia = new Lufia();%>
</BODY>
</HTML>
After I execute...
An error occurred at line: 18 in the jsp file: /jsp/ActivityGames.jsp
error: File C:\Program Files\Apache Tomcat 4.0\webapps\website\WEB-INF\classes\Games\Lufia\Lufia.class does not contain type Games.Lufia.Lufia as expected, but type Lufia. Please remove the file, or make sure it appears in the correct subdirectory of the class path.
Generated servlet error:
C:\Program Files\Apache Tomcat 4.0\work\Standalone\localhost\website\jsp\ActivityGames$jsp.java:85: Class Games.Lufia.Lufia not found.
Lufia lufia = new Lufia();
But if I comment this out....
This is my JSP file.
<HTML>
<HEAD>
<TITLE>Activity Games</TITLE>
</HEAD>
<%
String name = "";
String id = "";
name = session.getAttribute("name").toString();
session.setAttribute("name",name);
id = session.getAttribute("id").toString();
session.setAttribute("id",id);
%>
<BODY bgcolor="#cc99ff" text="#000000" link="#E3E3E3" vlink="#CCCCCC" alink="#FF0000">
<H3><%=name%>, you have enter Activity Games</H3>
<%@ page import="Games.Lufia.*" %>
<%//Lufia lufia = new Lufia();%> <--- comment this out.... (HERE)
</BODY>
</HTML>
The page shows but did not run my java class file..
Thanks again for trying to help me solve this problem of mine. : - )
Regards,
RainbowEnergies

Similar Messages

  • How can i call java class file in jsp page

    Hai,
    i wants to call .class file in jsp page.
    my class file is in C:\jsdk\bin.
    Thanks

    I'm not entirely sure what you mean by "calling a class file", but I'm going to assume that you want to do something like the following in your page:
    <%
    MyClass myClass = new MyClass();
    myClass.someMethod();
    %>etc
    If that's the case, then all you have to do is make sure that the class is in the servlet engine's classpath. You'll probably also need to include an appropriate import statement at the top of the page.
    Hope that helps.

  • 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

  • Extend a Java Class Inside a JSP Page?

    Hello all. I'm not sure if I am thinking about this right. But what I have is a BaseClass that all of my other classes Extend. I'm inside a JSP page and want to use all of the functionality of that BaseClass. Is there anyway I can EXTEND A CLASS INSIDE A JSP PAGE or am I smoking crack?

    Its an attribute of the page directive
    "extends="package.class"
    The fully qualified name of the superclass of the Java class this JSP page will be compiled to. Use this attribute cautiously, as it can limit the JSP container's ability to provide a specialized superclass that improves the quality of the compiled class. "
    http://java.sun.com/products/jsp/tags/12/syntaxref1210.html#15653

  • How to call java class file from jsp

    hi
    we need to call java classes (which are written separately in .java file )from jsp file. we need it for our project if anyone knows about please reply us.
    bye
    siva sankari

    you can call the methods in a lot of ways. you could use scriptlets with the
    <%@ page import="package.class"%> and then inside instantiate an object
    <%
         MyClass mc = new MyClass(parameters if any);
         mc.theMethodYouWantToCall();
    %>or as Madathil has stated,
    or use the JSP tags
    <jsp:useBean id="anyname" class="classname"/>and then use the getProperty tag
    or even Custom Tags

  • Call java class file into jsp file

    Hello experts,
    I wrote a class file which have validation functions it successfully created a class file of that java file.
    and I puted that class file into tomcat's ../WEB-INF/classes folder.
    And whenever I am going to execute the jsp page it give error like
    "regexFunctions cannot be resolved to a type"
    My class file is like follows,
    import java.util.regex.*;
        public class regexFunctions
        private static int SUCCESS = 0;
        private static int FAILURE = 1;
        private static int MISSING_INFO = -1;
        public static String ALL_STRING_REGEX = "^[a-zA-Z]+$";
        public static String ALL_NUMBER_REGEX = "[0-9]+";
    public static int checkForString(String inputtedValue)
             int retCode = FAILURE;
             if ((inputtedValue != null) && (inputtedValue.length() > 0))
                 Pattern pattern = Pattern.compile(ALL_STRING_REGEX);
                 Matcher matcher = pattern.matcher(inputtedValue);
                 if (matcher.find())
                     retCode = SUCCESS;
             return retCode;
    }My jsp page is like follows,
                <%
                     regexFunctions reg = new regexFunctions();
         String id = request.getParameter("txtId");
         int i = regexFunctions.checkForString(id);
               %>So Please Let Me Help Out...

    Put it into a package. Classes in packages can't access classes with no package, since about 2003.

  • Recompilation of java class invalidates taglib jsp page?

    Hi everyone,
              I have a JSP page which calls a custom tag library. On freshly compiling
              everything and
              calling the JSP page from a browser for the first time the output is as
              expected.
              However when ever I recompile one of the classes that get called anywhere in
              the tag
              library call the tag no longer works (internal error from the server).
              To get it to work I have to change the jsp page so that it recompiles.
              Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
              Any ideas?
              MTIA
              Craig
              

    p.s
              The following errors are in the log file.
              Is this another class casting problem?
              Does any one have any explanations?
              Ta
              Craig
              <ServletContext-General> Servlet failed with Exception
              javax.servlet.ServletException: runtime failure in custom tag 'MyTag'
              at jsp_servlet._taglib._jspService(_taglib.java:89)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              , Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java, Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
              <ServletContext-General> root cause of ServletException
              java.lang.ClassCastException: com.bt.db.MyTag
              at jsp_servlet._taglib._jspService(_taglib.java:77)
              at weblogic.servlet.jsp.JspBase.service(JspBase.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
              , Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextImpl.invokeServlet(ServletContextImp
              l.java, Compiled Code)
              at
              weblogic.servlet.internal.ServletContextManager.invokeServlet(ServletContext
              Manager.java, Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.invokeServlet(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.socket.MuxableSocketHTTP.execute(MuxableSocketHTTP.java,
              Compiled Code)
              at weblogic.kernel.ExecuteThread.run(ExecuteThread.java, Compiled Code)
              "crg" <[email protected]> wrote in message
              news:[email protected]...
              > Hi everyone,
              >
              > I have a JSP page which calls a custom tag library. On freshly compiling
              > everything and
              > calling the JSP page from a browser for the first time the output is as
              > expected.
              > However when ever I recompile one of the classes that get called anywhere
              in
              > the tag
              > library call the tag no longer works (internal error from the server).
              > To get it to work I have to change the jsp page so that it recompiles.
              >
              > Weblogic server 5.1 (no service patches yet) running on NT server SP6a.
              >
              > Any ideas?
              > MTIA
              >
              > Craig
              >
              >
              >
              >
              

  • Using java class files in JSP

    hi everyone,
    i am trying to import a java file in a JSP page..
    how do i do this???

    hi,
    <%@page import="yourpackagename.*" %>
    or
    <%@page import="yourpackagename.classname" %>

  • How to load java class from jsp page?

    hi all!
    Does anyone know how to load java class from jsp page?
    I try to load java class from jsp page.
    Is it possible to load java class fom jsp page?
    thanks and have a good day!

    What I mean is How to load/open java class file from jsp page?
    I think we can open Applet from jsp page by using
    <applet code=helloApplet.class width=100 height=100>
    </applet>
    but, how to open java class which is an application made by Frame?
    thanks and have a good day

  • How use class file in jsp(very urgent)

    i have class file called birds (birds is actually a xslt file transformed to java class file) now this class file i have to use in my jsp file. how can i use them. if possible can any one give me sample code please very urgent
    can any one help me

    java files
    import org.w3c.dom.*;
    import javax.servlet.http.*;
    import javax.xml.transform.*;
    import javax.xml.transform.stream.*;
    import java.io.*;
    public class XmlParser
         public String XmlParser()
              try
    String strXML= "employee.xml";
                   String xslFile = "employeeId.xsl";
                   TransformerFactory tFactory = TransformerFactory.newInstance();
                   StreamResult theTransformationResult = new StreamResult( new ByteArrayOutputStream() );
                   Transformer transformer = tFactory.newTransformer(new StreamSource(xslFile));
                   transformer.transform(new StreamSource(new StringReader(strXML)), theTransformationResult);
                   String output = theTransformationResult.getOutputStream().toString()
              catch(Exception e)
                   System.out.println(" ***** XmlParser.XmlParser ERROR ***** " + e);
    return output;
    using class files in jsp
    <%@ page import="com.qqqq.aaaa.XmlParser"%>
    <%
         XmlParser xmlParser          =     new XmlParser();
    out.println(xmlParser.XmlParser());
    %>
    i think it will help you.

  • Editor fails to close a java class file.

    jdev 10.1.3.4
    Even if I click the X on the editor tab, jdev editor does not close the file.
    File-->Close does not close the file either.
    File-->Close All closes all files, however.
    Instead of closing the file, it just jumps to the next file in the editor.
    This has been happening to me for a some time, and it happens with Java class files only.
    jsp or xml files do close no problem.
    Any idea how to fix this?
    Thanks for your help.
    Edited by: Yunki on Jan 7, 2009 2:54 PM

    Hi,
    since this doesn't reproduce on other machines, please let us know how this can be reliably reproduced
    Frank

  • How i load java class through javascript

    Hi,
    i want to load java class file at client side through the java script. Class file wich already at client side(client machine)
    tell me is it possible....
    thanks
    plzz mail
    [email protected]

    From your post it is not very clear what you want to do.
    1. Even if it was possible to load client classes using javascript, how on earth are you going to execute them ??? JavaScript and java are entirely different cups of tea.
    2. If it was an applet, then probably you can access some classes from the client machine. Definely the default packages. However, I don't know whether you can access other classes. That might lead to a security issue. Please check with a java securities expart.
    3. Loading a class from the client machine is DEFINITELY A BAD PROGRAMMING PRACTICE Use the codebase property on your applet tag to load the classes from the server.

  • How to convert a .jsp to a .java/.class file for use in peoplesoft

    Hi java/jsp experts,
    I want to convert a .jsp to a .java/.class file. is there a tool available, please let me know if you have any pointers....
    or can i do it manually:
    these are a few lines that the .jsp contains, and i would like to translate this to be in .java/.class format:
    <%@ page import="sun.misc.BASE64Encoder, javax.crypto., javax.crypto.spec."%>
    <%@ page import="java.util.StringTokenizer" %>
    <%@ page import="java.util.Map" %>
    <%!
    sb.append("<input type=\"hidden\" name=\"orderPage_serialNumber\" value=\"");
    sb.append(serialNumber);
    sb.append("\">\n");
    return sb.toString();
    %>
    how can i translate the above import statements and html elements from jsp to java, please let me know.
    Once i have the .java file created from the .jsp, I will compile .java to create the .class file and invoke the .class in peoplecode by using java apis available in peopletools.
    Thanks in advance.

    Is there a way convert a binary .exe file( compiled by
    another compiler) into Java .class/.jar file ? Anyone
    know of a free program that can do this?It's not possible. There are many decompilers and disassemblers for Java but nothing will take you from ANY binary to Java source. It would be the end of computing as we know it and the beginning of a new era -:)

  • Unable to import a java class in a jsp file

    Hi,
    I am trying to import a java class in my jsp.
    ------------------jsp---------------
    <jsp:useBean id="form" class="com.company.portlets.searchApps.object.SearchOBJ" scope="request" />
    <jsp:setProperty name="form" property="*" />
    <input type="TEXT" name="projectID" value='<%= form.getProjectID() %>'>
    When I run the above JSP, it says that class 'com.company.portlets.searchApps.object.SearchOBJ' cannot be found.
    Why?
    My project structure looks like this:
    Project
    +Application Sources
    ++com.company.portlets.searchApps.object
    +++SearchOBJ.java
    +Web Content
    ++htdocs
    +++searchappsportlet
    ++++SearchAppsPortletShowPage.jsp
    ++WEB-INF
    +++index.jsp
    +Resources
    ++SearchApps.deploy
    Please advice...thanks!

    The way that JDeveloper organized the files was like this:
    C:\jdev1012\jdev\mywork\WksSearchApps\Project\classes\com\company\portlets\searchAPPS\object\SearchOBJ.class
    I am assuming that JDeveloper puts the file where they are suppose to be...if not, how do I change that?
    thanks,
    hussain

  • SQLPLUS: How to verify that java class file have been loaded

    Hi All,
    I just loaded my Java class file using CREATE OR REPLACE JAVA.
    Java was created sucessfuly, but how can I check or find out if my file have been loaded correctly.
    I also found a command :
    SQL>exec myjava.showobjects
    but i don't have the loadjava utility install....is there any command from SQL PLUS?
    thanks

    Thanks for the sql command....after that query what do I do next to see if for example tree.class is in the dba_object.
    Sorry, I am a newbie and the question may be a bit generic .....

Maybe you are looking for

  • How to enter printer code into new eprint acount. first acount was deleted. (photosmart 7510)

    I eneterd my printer code into my eprint account, then mistakenly deleted the account. I set up a new account, but now I can't add the printer. I get the message "invalid code". The printer is a photosmart 7510.

  • Loose coupling transport  in PI 7.0

    Hi,   We are trying to implemet OTO.I am tring to do a loose coupling transport in PI 7.0 from DEV to QUA.  I have created one workbench request in se09 and have exported my IR object. I can see my exported IR object in IR>Tools>Find transports.  But

  • UDT Lob buffer overflow in Initial Load

    Hi All I'm doing an intial load for one table which is having ORDIMAGE column  , Here is my prm details : ==================================================================== EXTRACT INIT_FFU -- ENVIRONMENT PROFILES setenv (ORACLE_SID = "trfdv") sete

  • Syntax error in GP_ERR_RSAPTD1

    I encountered this error while attempting to activate my InfoSource for 0fiar_C02 cube "Syntax error in GP_ERR_RSAPTD1_____________, row 25 (-> long text) Message no. RG102 Diagnosis "DTFIAR_1" must be a flat structure. You cannot use internal tables

  • Java API - Urgent!!!!

    Expensive Friends, I am with some problems in the development of a solution to capture native events of a cellular telephone... Would like that somebody me of this a light, or same indicated a full bibliography (sites, books, codes of example) for us