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

Similar Messages

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

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

  • 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 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 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 use .mod files from a JVC camcorder?

    Hi All,
    I'm trying to find the proper workflow for using .mod files from a JVC Everio model camcorder. I was able to transfer the files onto my system by simply using the included usb cable from the unit. It simply mounted the camera's flash card on my desktop and I was able to drag all of the files from it.
    As others have posted, the .mod files are not accessible using the Import function in FCP. I am able to open them with MPEGStreamClip as other have suggested. My question is, how should the files be converted to use with FCP and/or DVDSP? In MPEGStreamclip the file shows the video stream as: 224 MPEG-2, 720 × 480, 16:9, 29.97 fps, 8.40 Mbps, upper field first. I tried a few of the demux functions. The straight demux to .m2v & .ac3 yields a file that opens in QT, but it shows up as a 640x480 file and is noticably squeezed. Using the demux unscaled yields a file that opens in QT as a 720x480 file and looks somewhat better. And using the demux to headed yields as file that opens in QT as 720x404 and presumably is the correct 16:9 ratio.
    Trying to use those same files in DVDSP didn't get me very far. If I create a new HD project in DVDSP I can import the straight demuxed file and the headed file. The unscaled file won't import. If I add the imported files to tracks the straight demuxed one will play in the simulator but the headed one simply shows a green screen.
    I'm hoping that since MPEGStreamclip can play the files, its just a question of figuring out the proper export/conversion settings. My end goal is to produce a dvd of the footage (not exactly sure if I should be using an HD project or a SD project set to letterbox). I also need to produce a web-ready version of the footage. I haven't tried this yet but I'm assuming that one of the QT exports from MPEGStreamclip will get this done correctly.
    Hopefully someone has a workable solution for these files.
    Thanks,
    Chris

    Hi all,
    I looked further on this forum and found others that had the same problem. One suggested connecting the cam corder first, then start iMovie, then wait for a few minutes. I did this and it worked!!!!!
    Problem solved.
    Thanks.

  • How to generate a file from JSP form

    Hi,
    I want to generate a file from the informations of a form(JSP).
    Which classes do I have to use ?
    Thanks.

    Of course you have to use the standard servlet classes to retrieve the request parameters from the form.
    ie request.getParameter();
    package "java.io" gives you File input/output ability.
    If you are generating a text file, thats probably the BufferedWriter and FileWriter classes.
    Cheers,
    evnafets

  • How to use dreamweaver files in jsp?

    Hello All
    I am developing jsp files in which i want to use macromedia dreamweaver files i.e flash button and flash text. I am building jsp files in JBulider. Can anyone tell me how to use or bring in these dreamweaver files in the JSP files? Will be greatful for any help given.
    Arshad

    You should be able to just bring the files into DreamWeaver. It should edit the HTML part of the JSP just fine.

  • How to use keystore file from native android project.

    Android apk upload fails with error 'The apk must be signed with the same certificates as the previous one'.
    Out of the frying pan, into the fire.
    How to convert .keystore file to .p12 file?

    "Bobby Digi" <[email protected]> wrote:
    Hi,
    Is there a way to use .keystore file with BEA Weblogic 6 or 6.1 ?
    I used keytool to create private key and public key..
    I do not know how to tell weblogic 6 to use it....
    Can this be done through the GUI or do I have to add something to the.xml
    config file for the site?
    Thanks,
    Rob
    nope. with 7.0 you can do that.
    >
    >

  • How to protect class files from being decompiled?

    any ideas
    guide me

    You may consider looking into Java native compilers.
    I'm referring to compilers that take existing Java
    code and convert them into native executables rather
    than class files which are interpreted.yeah... kills portability too.

  • How to write to log files using java files from JSP

    Anybody knows different options in writing to log files using JSP?

    Do you have an example?in the init() method of the servlet put the following
            FileOutputStream out = new FileOutputStream("your-log-file");
            PrintStream ps = new PrintStream(out);
            System.setOut(ps);
            System.setErr(ps);load the servlet on startup using <load-on-startup> in web.xml

  • How to get .class files from a JAR at runtime

    Hi. I wrote a program that load the classes it find in the "prog/components" directory. It enables me to add new components without messing with the code of the main program. Everything worked fine when wrote a batch file - but I want to create a JAR file. In the Batch file I gave the path to those files for the class loader in a loop, and it was "prog.components/" + filename[i] (I get the file names by using a FileFilter).
    My question is - how can I obtain the files in the prog/component directory inside the JAR? WHen I left it as it was in the BATCH it didn't work because there wa no prog/component dir outsiede the JAR. What should I do?

    Thanks man, that was really helpful! I wrote some piece of code that inserts the file names I want to an ArrayList. However, I wonder how you would make the program list all the files in the "prog.jar/prog/components/" directory? I think your code would be better tahn mine since you've coped with it before. Could you write the code snippet?

  • How to use .as files from AS3 project into Flex project

    I'm new.
    I created a ActionScript 3 project
    I created 2  .as  files, which put up a Sprite which moved around.  It worked fine.
    Now, I want to put that onto my web-site.
    So I created a Flex Builder 3 project.
    I moved those 2 .as files into it.
    I added code to access and display the moving Sprite.
    But, each attempt gave me an empty screen.
    My main confusion is the following:
    I have class  BaseClass in file 1
    and  SubBaseClass extends BaseClass in file 2.
    Within the Flex project  .mxml  file, how do I reference the  SubBaseClass so that the object will appear?
    I tried things like:
    <mx:Application ... completionComplete="init()" >
    <mx:Script>
    <![CDATA[
    public function init():void
      var myclass:SubBaseClass = new SubBaseClass();
      addChild(myclass);
    etc (ending stuff)
    What do I need to do to make this work
    Thanks
    ---- john

    I have done what you have recommended, the ear file is successfully created.
    However when I deploy to the J2EE server, I get the following error.
    Result
    => deployment aborted : file:/C:/DOCUME~1/xxxxx/LOCALS~1/Temp/temp41836xBtrService.ear
    Aborted: development component 'xBtrService'/'abc.com'/'localhost'/'2005.06.22.17.30.10':
    Caught exception during application deployment from SAP J2EE Engine's deploy service:
    java.rmi.RemoteException: Cannot deploy application abc.com/xBtrService.. Reason: Exception during generation of components of application abc.com/xBtrService in container EJBContainer.; nested exception is:      com.sap.engine.services.deploy.exceptions.ServerDeploymentException: Exception during generation of components of application abc.com/xBtrService in container EJBContainer.
    (message ID: com.sap.sdm.serverext.servertype.inqmy.extern.EngineApplOnlineDeployerImpl.performAction(DeploymentActionTypes).REMEXC)
    Deployment exception : The deployment of at least one item aborted.
    Thanks,
    Manik

  • How to generate class files from wsdl

    I have upgraded weblogic from 9.1 to 10.3.5 and java from 1.5.0_06 to 1.6.0_27
    Do I have to regenerate my webservices classes like the stub ,impl and service class.
    also there are a few changes in the wsdl .
    Please help me how to generate classfiles from wsdl ?
    Please help.
    Thanks,

    Did you ever get an answer to this question? Did you proceed forward with the use of WSIF or did you select an alternative.
    Ernie :)

Maybe you are looking for