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.

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

  • Using class method in JSP

    Is it possible to use method from ordinary .class file in jsp file?
    If it is, please explain.

    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
         org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)
         org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)
         org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
         org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

  • Error when using %@ include file="/test.jsp"%&

    UsingNitrox version 2.1 M3 (build 419 06022005):
    with jdk version: 1.5.0_03 and Tomcat 5.5.9
    This is the error :cry: when using <%@ include file="/test.jsp"%> in jsp:
    Severity     2
    The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files (test.jsp)
    It used to work in previuos version of Nitrox. I can't use struts tiles because the tiles content is dynamic (run time) and I need it to be static (at compile time).
    Have you encountered this problem? What is the fix? Nitrox bug?
    I need your help please,
    Alberto

    M7,
    I found the problem :wink: . In the java Build path having the default (ALL) is not picking up the content of the package. I had to use add multiple and include all the folders and subfolders (many L) in my packages. After that I added *.java and *.properties to select all the java files. Now it is working. I assume this is a bug in Nitrox. The default ALL should include the all the files in the path.
    Thanks,
    Alberto

  • How using mp4 files on final cut pro x

    a can't impot any mp4 (I don't want converter to mov) file in to fcp x.
    how using mp4 files on final cut pro x?

    MPEG-4 is  delivery framework and should never be used in production. At the very leasgt you should optimize the media when you import it.

  • Pls tell me use %@ include file="myfile.jsp"% with endcoding UTF-8??

    My jsp pages use some endcoding as UTF-8.
              When I use <%@ include file="myfile.jsp"%> endcoding lose format UTF-8. But
              if I use <jsp:forward page="myfile.jsp"/> it work fine.
              Pls tell me use <%@include %>
              (I use Jbuilder 6 and weblogic server 6.1)
              Thanks .
              

    From http://java.sun.com/products/jsp/tags/12/syntaxref1214.html#8828 (emphasis mine):
    page="{ relativeURL | <%= expression %> }"
    The relative URL that locates the resource to be included, or an expression that evaluates to a String equivalent to the relative URL.
    The relative URL looks like a pathname--it cannot contain a protocol name, port number, or domain name. The URL can be absolute or relative to the current JSP page. If it is absolute (beginning with a /), the pathname is resolved by your web or application server.
    You could use a servlet in your "path" attribute and have that servlet read and return the page from a different server; there are ways to do what you want, but <jsp:include> isn't one of them.

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

  • Urgent,java Error when compiling class file for jsp

    Hi!
    Reference to statement is ambbiguous,both class java.sql.statement in java.sql and class.java.beans.statement in java beans match.
    this is my file . When i comment the java.import.bean headre it does compile but my server is not able to recognize the class file.,Cud someone help me.
    THis is my source file
    package dbmg;
    //import java.beans.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class DbBean
    Connection con;
    ResultSet rs;
    String sql;
    boolean queryType;
    int edited;
    public DbBean() throws Exception
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:Forums");
    public void setQueryType(String s)
    queryType=s.equalsIgnoreCase("select");
    public void setSql(String s)
    sql = s;
    synchronized public void processRequest(HttpServletRequest req) throws
    Exception
    if (queryType)
    Statement stmt=con.createStatement();
    rs=stmt.executeQuery(sql);
    else
    PreparedStatement ps=null;
    ps=con.prepareStatement(sql);
    int count=0;
    String sqlParam,paramValue;
    boolean set=true;
    while (set)
    count++;
    sqlParam="param"+String.valueOf(count);
         if (sqlParam==null)
              set=false;
              continue;
    paramValue=req.getParameter(sqlParam);
         if (paramValue==null)
    set=false;
    continue;
              else
                   paramValue=paramValue.trim();
    try
                   ps.setString(count,paramValue);
              catch(Exception ex)
                   set=false;
                   continue;
    try
    edited=ps.executeUpdate();
    catch(SQLException e)
    edited=0;
    public Connection getConnection()
    return con;
    public ResultSet getResultSet()
    return rs;
    public int stored()
    return edited;
    public void closeCon() throws Exception
    con.close();
    rs = null;

    No need of commenting your import statement. Whenever there is ambiguity, you can use full class name (with package).
    Like,
    java.sql.Statement stmt=con.createStatement();
    Now there is no ambiguity.
    Sudha

  • Using java files with JSP

    Ok, so im pretty new to this JSP lark and have a question.
    I have Java Classes resting in .java files, i need to know how
    do i link these files to my .jsp page so that the classes/variable etc.
    declared with the java files are recognised when they are come
    across in the .jsp file.
    I dont know if I have explained that properly.

    Just include this statement at the top of your jsp:
    <%@page import="yourpackage.yourclass"%>
    The .java files should of course be compiled into .class files prior to using (and you don't include the extension when importing).

  • What is the syntax for calling function from class file by jsp

    does anyone here knows what is the syntax of how to call a function from java class file by javascript code or any way to call it?
    and where should i put the calling function code? because the function is called depend on the user click.
    for example
    <%=pc.functionName(a,b)%>
    for the variable a and b, how can i get the value from html textbox and put it in a and b...
    urgent needed...
    thx

    Jsp's are executed before the Html forms are created and loaded. Dont try to use a java code function calling on a javascript click. You'll have to explicitly redirect it into a servlet where in you can call the function you want.
    Well! another way could be using AJAX. That seems to be powerfull enough and it might also serve your purpose.
    Hope this helps

  • How to download files in jsp code {through save dialog}

    can you help me to download files in jsp code {through save dialog}
    i use the following code but it saves the jsp page instead of the downloaded file but with the name of the wanted file to be downloaded
    response.setHeader("Pragma", "public");
    response.setHeader("Cache-Control", "no-cache");
    *** download file
    if((trans !=null)&&(trans.equals("download")) )
    response.setContentType ("application/x-download");
    response.setHeader ("Content-Disposition","attachment;filename=\""+fileName+"\"");
    %>
    <script>
    window.location.href=<%=gallerypath+fileName%>';
    </script>
    <%
    trans="";
    //System.out.print("download : "+fileName );
    //***************************************

    Can you try below code, It should work...
    <%
    String myFileName = request.getParameter("fileName");
    response.setContentType("application/octet-stream");
    response.setHeader("Content-Disposition", "attachment; filename=\"" + myFileName + "\"");
    String root = "D:/";
    InputStream in = null;
    ServletOutputStream outs = response.getOutputStream();
    try {
    in = new BufferedInputStream
    (new FileInputStream(root + myFileName));
    int ch;
    while ((ch = in.read()) != -1) {
    outs.print((char) ch);
    finally {
    if (in != null) in.close(); // very important
    outs.flush();
    outs.close();
    in.close();
    %>

  • Business Objects Customization Using Class file without net bean

    Hi,
    Any one please help me out.
    my requirement is like I want to use Business Objects SDK
    <%@ page import="com.crystaldecisions.sdk.framework.CrystalEnterprise" %>
    above is example..
    in Class file of Java without using netbean.
    I try to do this with creating Batch file add all Jar file and set path and but its not working.
    Also can I Login Into business Objects through class file not using netbean(means from command prompt)
    and create user group into CMS.

    Please find following servlet code who dont understand my requirement.
    * GroupCreation.java
    * Created on September 2, 2008, 3:47 PM
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import com.crystaldecisions.enterprise.ocaframework.ServiceNames;
    import com.crystaldecisions.sdk.exception.SDKException;
    import com.crystaldecisions.sdk.framework.CrystalEnterprise;
    import com.crystaldecisions.sdk.framework.IEnterpriseSession;
    import com.crystaldecisions.sdk.framework.ISessionMgr;
    import com.crystaldecisions.sdk.occa.infostore.IInfoStore;
    import com.crystaldecisions.sdk.occa.managedreports.*;
    import com.crystaldecisions.sdk.occa.security.ILogonTokenMgr;
    import javax.servlet.http.Cookie;
    import com.crystaldecisions.sdk.occa.infostore.*;
    import com.crystaldecisions.sdk.occa.pluginmgr.*;
    import com.crystaldecisions.sdk.plugin.CeProgID;
    import com.crystaldecisions.sdk.plugin.desktop.user.*;
    import com.crystaldecisions.sdk.properties.*;
    import javax.servlet.http.HttpSession;
    * @author prashant.joshi
    * @version
    public class GroupCreation extends HttpServlet
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    HttpSession session = request.getSession(true);
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    String cms = request.getParameter("CMS");
    String username = request.getParameter("UserID");
    String password = request.getParameter("Password");
    String auth = request.getParameter("Aut");
    IEnterpriseSession enterpriseSession = null;
    try
    ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();
    catch(SDKException e)
    out.println(e.getMessage());
    Exception failure = null;
    boolean loggedIn = true;
         // If no session already exists, logon using the specified parameters.
    if (enterpriseSession == null)
    try
    // Attempt logon. Create an Enterprise session
    // manager object.
    ISessionMgr sm = CrystalEnterprise.getSessionMgr();
    // Log on to BusinessObjects Enterprise
    enterpriseSession = sm.logon(username, password, cms, auth);
    catch (Exception error)
    loggedIn = false;
    failure = error;
    if (!loggedIn)
    // If the login failed, redirect the user to the start page.
    out.println("<SCRIPT language=\"javascript\"> " +
    " alert (\"Sorry - you could not be logged on to this server." +
    " Ensure that your user name and password, as well as the CMS name are correct." +
    "\"); </SCRIPT>");
    out.println("<META HTTP-EQUIV='refresh' CONTENT='0;URL=LogonPage.jsp'>");
    return;
    else
    try
    // Store the IEnterpriseSession object in the session.
    session.setAttribute("EnterpriseSession", enterpriseSession);
    // Create the IInfoStore object.
    IInfoStore iStore = (IInfoStore) enterpriseSession.getService("InfoStore",
    ServiceNames.OCA_I_IINFO_STORE);
    // Store the IInfoStore object in the session using the
    // helper functions.
    session.setAttribute("InfoStore", iStore);
    // Create the IReportSourceFactory object.
    IReportSourceFactory reportSourceFactory = (IReportSourceFactory) enterpriseSession.getService("PSReportFactory");
    // Store the IReportSourceFactory object in the session
    // using the helper functions.
    session.setAttribute("ReportSourceFactory", reportSourceFactory);
    // Retrieve the logon token manager.
    ILogonTokenMgr logonTokenMgr = enterpriseSession.getLogonTokenMgr();
    // Retrieve a logon token and store it in the user's cookie
    // file for use later.
    Cookie cookie = new Cookie("LogonToken", logonTokenMgr.createLogonToken("", 60, 100));
    response.addCookie(cookie);
    // LOCUse the plugin manager and the UserGroup plugin to create a new
    // UserGroup object._ENDLOC_
    // LOCIf the infoStore object is not found then display an error message._ENDLOC_
    IInfoStore infoStore = (IInfoStore) session.getAttribute("InfoStore");
    // LOCIf the infoStore object is not found then display an error message._ENDLOC_
    if (infoStore == null)
    throw new Error("_LOC_InfoStore object not found. Please logon again._ENDLOC_");
    IPluginMgr pluginMgr = infoStore.getPluginMgr();
    //IPluginMgr pluginMgr2 = infoStore.getPluginMgr();
    IPluginInfo userGroupPlugin = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
    // IPluginInfo userGroupPlugin2 = pluginMgr.getPluginInfo("CrystalEnterprise.UserGroup");
    // LOCCreate a new InfoObjects collection._ENDLOC_
    IInfoObjects newInfoObjects1 = infoStore.newInfoObjectCollection();
    IInfoObjects newInfoObjects2 = infoStore.newInfoObjectCollection();
    // LOCAdd the UserGroup interface to the new InfoObjects collection._ENDLOC_
    newInfoObjects1.add(userGroupPlugin);
    newInfoObjects2.add(userGroupPlugin);
    // LOCGet the new UserGroup object from the collection._ENDLOC_
    IInfoObject iObject1 = (IInfoObject) newInfoObjects1.get(0);
    IInfoObject iObject2 = (IInfoObject) newInfoObjects2.get(0);
    // LOCOnce you have the new UserGroup object, set its properties._ENDLOC_
    iObject1.setTitle ("Single Home Group");
    iObject1.setDescription ("It is Single Home Group");
    iObject2.setTitle ("Multi home Group");
    iObject2.setDescription ("It is multi Home Group");
    // LOCRetrieve the ID of the InfoObject (user group)._ENDLOC_
    // objectID = iObject.getID();
    // LOCSave the new group to the CMS._ENDLOC_
    infoStore.commit (newInfoObjects1);
    infoStore.commit (newInfoObjects2);
    catch(Exception ex)
    // If the User group is already created.
    out.println("<SCRIPT language=\"javascript\"> " +
    " alert (\"Sorry - The User Group is already created Please enter another User Group." +
    "\");</SCRIPT>");
    out.println("<META HTTP-EQUIV='refresh' CONTENT='0;URL=LogonPage.jsp'>");
    return;
    // If the User is Logged on the Business objects
    out.println("<SCRIPT language=\"javascript\"> " +
    " alert (\"UserGroup get created in CMS.\"); </SCRIPT>");
    out.println("<META HTTP-EQUIV='refresh' CONTENT='0;URL=LogOff.jsp'>");
    out.close();
    /** Returns a short description of the servlet.
    public String getServletInfo() {
    return "Short description";
    // </editor-fold>
    when I paste above code in simple notepad as class file and run this file from command prompt
    it gives error like following 1 example I getting 46 errors for different Business Objects classes
    symbol : variable CrystalEnterprise
    location: class GroupCreation
    ISessionMgr sm = CrystalEnterprise.getSessionMgr();
    Please help me Out.
    Thank you.

Maybe you are looking for

  • Urgent:  making multiple inspection characterstics in QP01 bdc

    Hi, I had made a BDC on QP01 in which i am able to upload 1 line for the inspection characterstic of a single Operation . Now the problem is there are around 10 to 15 lines for the inspection characterstic of a single Operation and i am not able to d

  • How do I play an audio clip embedded in a PDF file in Acrobat DC for iOS?

    It looks like playing audio clips from PDF files is currently not available on Acrobat DC for iOS, could this be enabled? Also it would be nice to be able to pause/restart/stop audio playback, see audio clip length and progress bar and jump to the de

  • WHT settings needed urgently

    Dear SAP FICO experts, I have assigned the project for WHT with FORM 16A.  So Pl send me the EWHT settings asap. Venkata Raju.

  • Kodo Connector in WebSphere 4.0.2

    Hello, WebSphere 4.0.2 supports JCA. Could I install the Kodo Connector in WebSphere? Are there any tests and/or documents? Andreas

  • Documents stack

    The documents stack opens from the dock with the folders in alphabetical order. Is there any way to alter this so that the folders can be grouped in a custom order, to match the way I have them in Finder? I can see there is a choice of name, date add