How to call class file from jsp without creating packages

i m using tomcat 5.5
i stored my class file into WEB-INF\Class directory
how to call that class file. from my jsp page.
i got some error.
i used package concept,that works fine.

i m using tomcat 5.5
i stored my class file into WEB-INF\Class directory
how to call that class file. from my jsp page.
i got some error.
i used package concept,that works fine.Then use packages.
As of Java1.4, you can no longer import classes from the default package (no package declared) into classes that are packaged.
All Tomcat classes are in packages, including the compiled JSP.
Therefore: Your classes need to be in a package inorder to be imported and used by the JSP.
Why the problem? If you know it works with packages, why try not to use them?

Similar Messages

  • How to use .class files from jsp

    hi i want to use .class files in my jsp program can any one help me

    so if you are using pacakges here is normal example...
    say you .java code is something like...
    package com.util;
    public Class BeanUtility{
    }place the .class file at WEB-INF/classes/com/util folder if those folders are missing create it and place the .class file there. or pacakage it as a jar file & put it into WEB-INF/lib folder
    Now in jsp you can either use jsp:Usebean tag or use normal scriplets to create an instance of the nessary class...
    here is an example for you
    <%@ page language="java" import="com.util.BeanUtility" %>
    <%
    BeanUtility bn = new BeanUtility();
    %>however,i'd suggest you to make use of JSTL / Inbuilt tag libraries /MVC 2.0 approach for better maintainance & readablity.
    Hope this might help
    REGARDS,
    RaHuL

  • How to find lost files from Iphone without back up

    How to find lost files from iPhone without back up?

    If you don't have a back up, there's no where to restore them from.

  • 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

  • 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

  • How to call java files from different directories

    hi, how do i call java files from a different directory??
    let say i got partA.java, and i need to include functions from partB.java which is in a different folder. how can i do that?

    Chicon wrote:
    Hi nuttynibbles,
    Before the class declaration in partA.java, you must have an import statement like :
    import someDirectory.partB;
    public class partA {
    ... and before you ask... you'll probably want to read through this http://java.sun.com/docs/books/tutorial/java/package/index.html

  • How to call text file in jsp

    Hi all,
    I can call html or jsp file from jsp file, but how can I call text file in jsp, I put my text file same lever asmy jsp file it don't work!
    where I should put the text file??
    thank you

    mary,
    since you knew the file name ,when clicked in name send to server,read the file and write to servlet outputstream.
    I think this would help you.
    If anything wrong in mycode ..forums will help you further
    BufferedInputStream bis=null;
    BufferedOutputStream bos=null;
    int bytesRead=0;
    byte buff[]=new byte[1024];
    File f=new File(test.txt);
    try{
         bis= new BufferedInputStream(new FileInputStream(f));
         bytesRead=bis.read(buff,0,buff.length);
         if(bytesRead!=-1){
              // create a BufferedOutputStream from ServletOutputStream
              bos=new BufferedInputStream(response.getOutputStream());
              do{
                   bos.write(buff,0,bytesRead);
              }while((bytesRead=bis.read(buff,0,buff.length))!=-1)
    }catch(Exception e){
         ////error handling
         }

  • How to execute batch file from JSP

    hi frens !
    i wanna know how to execute batch file from my JSP.i am using exec() method to get call the batch file. but its not working ....plz help
    here mine code:-
    File F = new File("C:/var.bat");
         try{
          if (F.exists())
            Runtime rt = Runtime.getRuntime();
            String url=F.getAbsolutePath();
             Process proc = rt.exec(url);
            proc.waitFor();
            proc.destroy();
            catch(Exception IOEx){
           System.out.println(IOEx);
      }Thanks and Regards
    Allwyn

    You might improve your chances of getting help if you do two things:
    1) Explain what "not working" means.
    2) ChangeSystem.out.println(IOEx); to IOEx.printStackTrace(); (in the eventhat is in fact related to "not working").

  • How to call external files from java?

    How to call external files in java. For example how to call a *.pdf file to open in its default editor(say Acrobat), or a *.html file to open in the default browser or a *.txt file in a notepad etc..,
    In my program i have *.chm (Compiled Windows HTML Help) help file. how to open it in its default editor it?

    Jayarathina_Madharasan wrote:
    no one answered my questionHi what wrong did i do...basically insulted all the volunteers here who took the time to consider your question and try to offer you help. Other than that, you did nothing wrong.
    From JavaRanch :
    And even if an answer doesn't solve your problem, even if it should totally miss the point - the best thing to do to motivate others to continue trying to help you is showing respect and gratitude for the investment of time that was put into dealing with your issue.
    Edited by: Encephalopathic on Apr 14, 2008 10:01 AM

  • How to call a webservice from JSP

    I want to call a webservice from JSP? How can I do that .

    Check out this OBE and I think it's pretty well documented in JDeveloper help.
    http://www.oracle.com/technology/obe/obe1013jdev/10131/wsfromplsqlpackage/devwsfrom%20plsql.htm
    Thanks, Rob

  • How to call Java Beans from JSP (eg.put them in a WAR or package)

    Can anyone explain to me what are the steps and ways to call java beans from JSP?

    1st, put the javabean classes in the right place:
    the web-inf/classes/your_bean.class directory of corresponding web application
    2nd in your jsp page:
    <jsp:useBean id="obj_var_name" class="your_bean"/>
    <jsp:setProperty name="obj_var_name" property="smthg" value="smthg_calue"/>
    Micheal

  • How do you delete files from iCloud WITHOUT having them deleted from devices?

    I need to delete files from iCloud WITHOUT having those files deleted from all my devices.  How do I do that?

    Just got off the phone with Apple customer service.  It seems there is no around this problem.  Once you use iCloud, you're screwed. The day you decide you don't want to have certain files store in iCloud, but you still want the files accessible on your computer, you have to spend valuable time copying/hiding a set of files on each device, and then re-setting up those same files in each device they way they should be once you delete them out of iCloud.  Same thing if you decide to cancel your lCloud account. 
    No software should have the ability to hijack your data this way.   

  • How to Call .XDO file From Java Program

    Hi,
    I have developed a report in using BI Publisher version 10.1.3.
    I created the report and it only created XDO files. If I want to call XDO file from Java program how I can do that.
    What are the APIs available to do that.
    Thanks
    -Ashutosh

    Hi,
    the JavaAPI didn't work with the xdo-Files. But you can create a proxy stub for the Web Service API of BI Publisher which uses the xdo's in the repository.
    regards
    Rainer

  • Calling jar file from jsp - serious problem !

    Hi there, I'm trying to call a jar from a jsp file. I need an import clause in my jsp, to the class I want to use.
    I'm using eclipse, and while i"m writing "<%= " and the begining of my class name , he autocompletes it and automatically puts an import of my class in the top of the html. It is very convenient , but the problem is that he underling the class name (in the impot: <%@page import="myClass"%>), and I get "The import myClass cannot be resolved" error.
    I got an advice to put my class in a package, since it was in a default package. I did it. But now I have 2 problems:
    1. I can't run my jar in command window: java - jar myJar.jar. in gives me: Exception in thread "main" java.lang.NoClassDefFoundError....
    2. I still get an error - "The import myClass cannot be resolved" in the jsp, although I threw the old jar (that his class I want to use was out of package), and brought a new jar after creating it.
    I hope I managed to clarify myself. I'll be thankful of any help !!!

    Hi MSoldier.
    There are two ways to do this:
    1) You use the java.lang.Runtime classes to start the java application in your JAR file, just like you would have done it from the command line. The Runtime class has three different exec() methods that can be used to run any program just like you would from the command line. Remember, using this method you will have to write everything just like if you run your Java application from the command line, incl. classpath etc. This way your Java application will be run as a separate process. When the application finishes the process is shutdown and the resources (RAM etc.) taken by it freed, just like when you shutdown any other application.
    2) You can open the JAR file yourself from inside the JSP page, look inside the META-INF file to find the main class, and then calls the main class main method. There is an example of how to do this in the Java Tutorial available from Sun under the JAR files track. Check these links :
    The Java Tutorial at Sun
    http://java.sun.com/docs/books/tutorial/
    The JAR File Tutorial at Sun
    http://java.sun.com/docs/books/tutorial/jar/index.html
    Opening JAR Files via the Java JAR File API
    http://java.sun.com/docs/books/tutorial/jar/api/index.html
    Note however, if you have just created some classes that you want to use from inside your JSP pages, and not a separate application that needs to be run separately, you should just include the JAR file with your custom classes inside the WEB-INF/lib directory. These classes are then automatically available to your JSP pages, just like the rest of the Java API.
    I hope this answers your questions,
    Kind Regards,
    Jakob Jenkov
    Software Architect
    Jenkov Development
    www.jenkov.com

  • Calling class methods from jsp

    hi - this seems like it should be painfully obvious but I am missing something somewhere and can't seem to get it to work.
    The end result I am looking for is to be able to call a method similar to how I would do it in PHP or ASP.
    To do this I have writte the following class (just as an example) and combpiled it to /WEB-INF/classes/com/example/util/Echo.class:
    package com.example.util;
    class Echo
    public static void main(String[] args)
    System.out.println(args[0]);
    I then have a sample JSP that I attempt to use this in that looks like:
    <%@ page import="com.example.util.Echo" %>
    <%
    RDmail("I'm using my Echo class.");
    %>
    My expectation would be that when I run this page in a browser, I see the text "I'm using my Echo class." printed out on the page. Instead I get the following error:
    An error occurred at line: 1 in the jsp file: /classtest.jsp
    Generated servlet error:
    [javac] Compiling 1 source file
    /var/tomcat4/work/Standalone/localhost/raindance/classtest_jsp.java:47: cannot resolve symbol
    symbol : method Echo (java.lang.String)
    location: class org.apache.jsp.classtest_jsp
    Echo("I'm using my Echo class");
    ^
    1 error
    What am I doing wrong?

    Umm... I'm not entirely sure what you're attempting to do, but it looks like there's some discrepancy between your error message and your code...
    RDmail("I'm using my Echo class."); in your code
    and
    Echo("I'm using my Echo class"); in your error message.
    Is this just a cut/paste error?
    Also, the main() method is only called from a command line, and will not be run when you instantiate your bean in a JSP. If you want to have your String printed out when you create a new object, you should put the print statement in the constructor. Which would then be called when you created a new object..
    Echo e = new Echo("I'm using my Echo class");
    Or, you could create a static method inside Echo.java that prints out the statement.
    Finally, your System.out most likely will not print to your browser, but probably to a standard log, or perhaps a command window.

Maybe you are looking for

  • PDF file Not opening in Main Table

    Hi, I have added PDF lookup field in my main Table in console. I m able to import PDF file in PDF table ( after making Allow Invalid PDFs as YES) I have also imported PDF file in Main table field. But here PDF file is not opening. I m able to open PD

  • Setup.exe won't run on Windows XP?

    I am trying to install Oracle 8.1.7 on Windows XP (Pro). When I run setup.exe, nothing happens. The task manager process list shows that setup starts and it starts jrew.exe, then both disappear from task manager process list and nothing happens. How

  • OBIEE Home Page - Clear Recent Items

    Hi, I had a dashboard, which I deleted. I still see that dashboard in recent item, as that was used before being deleted. Is there a way I can clear all recent items and reset the home page? (I am using OBIEE 11g) Thanks Edited by: mail2diptesh on De

  • FB70:Field movement 20L5 not found

    Hi there, does anyone met problem during FB70 said field movement 20L5 not found. i pasted log as following Field movement 20L5 not found in client 200 Message no. GI168 Diagnosis The field movements could not be processed because of table T888M. Pro

  • General question on applets and proxies

    I noticed that while recently surfing the web using an anonymous proxy that a web site I went to running a java chat applet was able to display my true ip address. Does anyone know how this is done? Does the server run an applet that bypasses the bro