How to invoke a 6 parameter java class within jsp

i have just begun to learned jsp and java recently, so have the question below:
Situation:
My boss asked me to do a project for doing online data mining.
He requested the thing below:
1. Write a webpage by jsp with some textfield or pull down meun to get the parameter for getting the opinion and the parameter needed for the java class.
2. When the user click the buttom in the website, then the java class have to be invoked.
Questions:
1. ask i put the .java in the server, i can simply use cmd and type the following command:
java -Xmx800M P05context 1 1 3 6 F01xyz.txt F10xyz.txt
which F01xyz is the prepared text file for the java class to read and the F10xyz.txt is the output file generated by the P05context.class
but i don't know how to invoke the P05context.class by jsp
My boss have suggested me two ways to do this:
a. write a java virtual class to execute the java program.
but i don't know how to write.
i think conceptualy will be like this :
public class run_java
public void run java(parameter1,parameter2....,parameter6)
//run the cmd command
//java -Xmx800M P05context 1 1 3 6 F01xyz.txt F10xyz.txt
b. write a javabean in the jsp. and i have try to use this code(at the end of the message:
but the tomcat server reply a internal error to me
how cani do ?
the jsp file-->
<jsp:useBean id="test" scope="session" class ="P05context" />
<html>
<head></head>
<body>
<% test.P05context(1,1,3,6,F01xyz.txt,F10xyz.txt); %>
</body>
</html>

I still don't see why the form (the origin of the request) has to be a JSP, As you say, it might be static but forms I've written have usually had some kind of menu framework arround them and other variables. Also if the input is invalid you usually want to re-present the form, with an error message and the fields pre-populated according to what the user put in before. That does require a JSP and you may as well use the same JSP for an empty, as for a rejected request.
the response to the form should be handled by a servlet. Both is HTML, but the
form is static, and the reply dynamic. Using the combination; a servlet to do the data processing and a JSP to format the results is more flexible in a number of ways. For example, suppose you find the need to present the data form in, say, Greek? You don't want the processing to be duplicated in English and Greek versions of the results JSP.
Suppose the boss wants to turn a graphics designer loose on your HTML. Don't want him mucking about with your processing code do you.
The servlet typically takes the function of controller in the model/view/controller paradigm.
Code in a servlet is cleaner, better formatted and easier to access with a debugger.

Similar Messages

  • 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 to invoke BPEL process from JAVA API

    Hi Guys
    Any idea if you can tell me how to invoke BPEL process from JAVA API ?
    What to do in BPEL process manager to achieve that?
    Regards
    Deepak

    See http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28981/invoke.htm#sthref1373 and the JavaDocs http://download-west.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm.

  • Java Classes and JSP`s (urgent)

    hi, my question is:
    How can i invoke normal java classes` methods using Jsp`s for this??, is it possible??, if it is, then how do you do this, and where do you have to put the java classes in order to find them from a jsp.
    thanks

    Hi,
    You can access normal java classes in JSP pages. You have to import them in the header like this:
    <%@ page language="java" import="//your java class file with package"%>
    or if u r using java beans, then use the <usebean> tag. Put the java classes in the classes directory. Which server u r using? If it is JWS, then u have a specified classes directory, where u have to put all the class files along with their packages. Hope this will help.
    atanu.

  • Calling java class from jsp page

    Dear Friends.
    I wrote jsp page and java class.
    Am calling java class from jsp page. after processing result,
    I have to refresh jsp page from java class.
    processing time may take 5 minutes or 1 minute etc. that depends on user.
    Can It be possible ? if possible , How ?

    Ok, I get a very strange error now:
    org.apache.jasper.JasperException: Unable to compile class for JSPerror: An error has occurred in the compiler; please file a bug report (http://java.sun.com/cgi-bin/bugreport.cgi).
    What is this??? Anyone?

  • Java class into jsp page

    hi i,m a beginnner
    how can i run my own java class into a JSP file?
    please help me!
    thanks

    If you understand the OO concepts and wrote the Java class right, then all you need to do is something like:YourJavaClass yourJavaClass = new YourJavaClass();
    yourJavaClass.doSomething();After all I rather recommend to use servlets for business logic instead of JSP (read: scriptlets).

  • Triggering Java class within wls using Autosys

    Is it possible to trigger a Java class within the weblogic server externally using an utility like Autosys ?

    Dont know autosys that well but I would guess you would have to invoke java
    and run a starter class.
    There is a good product out there called Flux which is an all java based
    scheduling system that has some great scheduling features and is made
    to trigger either Session Beans, Add entrys to JMS Queues/Topic or
    fire a java class when a scheduled event is fired.
    try
    www.simscomputing.com
    Anil wrote:
    Is it possible to trigger a Java class within the weblogic server externally using an utility like Autosys ?

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

  • How to take C++ struct in java class

    Hi
    My requirement is c++ dll will invoke my java. C++ will pass struct to my java class, I have to take the struct values after i have to process the values and I will get bulk data, this bulk data i have to fill in c++ struct.
    Can you guide me how to do.
    Thanks,

    If you want some code sample, at least post your C struct and the corresponding Java class.
    Please paste your code between code tags exactly like this:
    &#91;code&#93;
    your code
    &#91;/code&#93;
    You can do that by simply pasting your code in the message area, highlight it and then click on the code button above.
    You may read the [url http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips for more information.
    Regards

  • How do I call a simple java class from a bpel process?

    Hi.
    In JDeveloper 10.1.4.3.0 I've created a simple java class that does an ftp get operation followed by an unzip. The class uses some 3rd part libraries (jars).
    I want to use a simple bpel process to schedule a daily execution of this java class, and deploy it all to our SOA-server, - and was looking into using the <bpelx:exec> function.
    The java class and the bpel process is all stored in the same JDeveloper project.
    How do I put this together so that both my java class and the necessary jars are available to the bpel process?
    I've looked into the JavaExecSample.bpel, and it's says something about "...the class com.otn.samples.javaexec.CreditCalculator is locally packaged with this BPEL process".
    How do I do that?
    Can I make it and test it all locally from my workstation (only JDeveloper installed, I guess there's nothing that can execute the bpel code?), or do I have to compile class etc (make war-file?) and deploy to SOA server (BPEL-INF/lib or classes?) before anything can be tested?
    (I guess all this is simple, once you know how, but being a newbie to this I need a shove in the right direction :-)
    Regards,
    -Haakon-

    To create a java class and dependent jars inside the BPEL process project you need to do the following:
    1. Right click on your BPEL process project and select New and then Java Class from the Items.
    2. Make the BPEL process project, JDeveloper would compile the java classes and add them into the BPEL suite case jar, see the output folder and check the BPEL suite case jar file for java classes and dependent jars.
    You can test your Java classes from JDeveloper IDE, no need to deploy the classes on SOA server. When you make the BPEL project it compiles .bpel files and Java classes. You can test your classes once .bpel file and java classes compiled successfully.
    Regards,
    Dharmendra
    http://soa-howto.blogspot.com

  • 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 find the location of java class files at runtime?

    Does anyonw have an idea how to get the file name of a java class given the binary name?
    I mean how can I get the file name for my class myPackage.myClass?
    I am looking for a function which takes "myPackage.myClass" as input and returns
    "c:\\javaprojects\\myPackage\\myClass.class".
    I tried to do it with the LassLoader class but it did not work. Does anyone have an idea if the Java core API already has a function which does that?
    Thanks, Bernhard

    Hi ,
    It is a simple SAMPLE code , you think and build a logics to handle all classes.
    Try this sample, It doesn't handle the inner classes you put logic to handle the logics for inner classes.
    The inner class format is it contains the character $ in the File location but inside the code you put "." instedad of "$" you to find out or put trials.
    package pkg1;
    import java.io.* ;
    import java.util.* ;
    import java.util.zip.* ;
    public class ClsB {
         private static Vector clsPaths ;
         public static Vector getPaths() {
              if( clsPaths == null ) {
                   String paths = System.getProperty( "java.class.path" ) ;
                   // In linux or solarise use the following
                   // StringTokenizer st = new StringTokenizer( paths , ":\n" ) ;
                   StringTokenizer st = new StringTokenizer( paths , ";\n" ) ;
                   clsPaths = new Vector() ;
                   while( st.hasMoreTokens() ) {
                        String path = st.nextToken() ;
                        File f = new File( path ) ;
                        if( f.exists() ) {
                             try {
                                  f = f.getCanonicalFile() ;
                                  clsPaths.add( f ) ;
                             }catch( IOException ioe ) { }
              return clsPaths ;
         public static String findClassPath( String fullClassName ) {
              Vector v = getPaths() ;
              for( int i = 0 ; i < v.size() ; i++ ) {
                   File f = ( File ) v.get( i ) ;
                   String path = findIn( f , fullClassName ) ;
                   if( path != null )
                        return path ;
              return null ;
         static boolean isJar( File jar ) {
              if( jar.isDirectory() )
                   return false ;
              try {
                   ZipFile zf = new ZipFile( jar ) ;
                   return true ;
              } catch ( ZipException ze ) {
                   // It is not a jar file
                   // you handle this
              } catch ( IOException ioe ) {
                   ioe.printStackTrace() ;
              return false ;
         static String findIn( File dirOrJar , String clsName ) {
              if( isJar( dirOrJar ) ) {
                   // It is something different because the class inside the jar file
                   // Simply I return the jar file location and the entry name ,
                   // but you put action what you want
                   if( isInsideJar( dirOrJar , clsName ) ) {
                        // All archieve file using the path separator is '/'
                        return dirOrJar.getPath() + "!" + clsName.replace( '.' , '/' ) + ".class" ;
              } else {
                   File f = new File( dirOrJar , clsName.replace( '.' , File.separatorChar ) + ".class" ) ;
                   if( f.exists() ) {
                        return f.getPath() ;
              return null ;
         static boolean isInsideJar( File jar , String clsName ) {
              try {
                   ZipFile zf = new ZipFile( jar ) ;
                   // All archieve file using the path separator is '/'
                   ZipEntry ze = zf.getEntry( clsName.replace( '.' , '/' ) + ".class" );
                   return ( ze != null ) ;
              } catch ( ZipException ze ) {
                   ze.printStackTrace() ;
              } catch ( IOException ioe ) {
                   ioe.printStackTrace() ;
              return false ;
         public static void main(String[] args) {
              System.out.println( findClassPath( "pkg1.ClsB" ) );
              System.out.println( findClassPath( "pkg1.pkg2.ClsA" ) );
    }

  • af:chooseDate - how to get selected month in java class

    <af:chooseDate id="choose_date_ID"
    binding="#{EventsBackingBean.choose_date_ID}">
    </af:chooseDate>
    in adf ,how to get the selected month value in the component.
    and if we change the the month from the drop down,then again new value should be reflected in java class.

    Hi Hoque,
    As per the documentation of af:choose at http://download.oracle.com/docs/cd/E12839_01/apirefs.1111/e12419/tagdoc/af_chooseDate.html
    "In order to indicate that a particular inputDate should be updated in response to chooseDate selection changes, the the inputDate's "chooseId" attribute must be set to the id of the associated chooseDate component.ts mentioned that the the af:choose "
    So, i believe that if you can create a binding to the af:inputDate component in your backing bean, you can extract the newly selected date in a ValueChangedListener using the getValue() function on the bound component.
    private RichInputDate chooseDateInput;
        public void setChooseDateInput(RichInputDate chooseDateInput) {
            this.chooseDateInput = chooseDateInput;
        public RichInputDate getChooseDateInput() {
            return chooseDateInput;
        public void chooseDateInput(ValueChangeEvent valueChangeEvent) {
          Date selectedDate = (Date)chooseDateInput.getValue();
        }Regards,
    Ryan

  • How to invoke my dll in java?

    hi:
    I use Jawin Type Browser generate two java files(DES_in_VBA.java,_DES_in_VBA.java),but I do not know how to use this two java files,beacuse this is my first to use Jawin. Can you tell me Where the two files should to be place,and how to use it good.I had read Jawin's docs,but can not understand it for my poor english.
    Thank you for your help again!!!
    I want use 'FuncPtr' to invoke it,but there can not found the match Invok_* file's.I do not know how to pass my function's paramters!
    There are two function's in my ".dll" file:
    Public Sub DES_Encode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)
    Public Sub DES_Decode(ByRef sCode() As Byte, ByVal sKey As String, ByRef bReturn() As Byte)
    Can you tell me how to invoke the two functions in java,and can you give me a example about how to invoke the two functions?
    Thank you for your help

    http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • How can i Make sys's java classes valid?

    I use Oracle 8.1.8.
    All the java classes in sys are invalid.
    How can I make it valid?
    thanks!

    Dear Chris,
    Sorry to disturb you.
    As I didn't browse Metalink yet, How could I browse METALINK With below Category?
    Thanks in advance,
    Orahar.

Maybe you are looking for

  • Individual Spry Data Repeat

    Hi, I'm trying to create a spry data set in a table from a XML data file. I have done that in below are the codings I obtained from Spry tool. <div spry:region="KomtarETA">   <table>     <tr class="TableHeader">       <td width="100">Route</td>      

  • Receiver SAP SFTP adapter-errorlog on SFTP server

    Experts, I am using receiver SAP SFTP adapter to connect to an SFTP server and send files.Receiver SFTP server is a VMS system.I could able to write the files to home directory of the user that has been given,but apart from writing the files I am see

  • Bluetooth Unavailable in 10.8.4 on 2011 iMac, any solutions?

    I did a restart on my iMac today and upon restart I had the squiggly line through the bluetooth icon and no bluetooth in the system preferences. Tried SMC reset, PRAM reset. Nothing works. If it's a hardware issue, can i replace the bluetooth compone

  • IDOC to IDOC using IWay Adapter?

    Hi, I believe I have sent my post to the wrong forum. Sorry about that. Can anyone here help? Please. The post I am talking about is: IDOC to IDOC using IWay Adapter? P.S.: How can I move that post to the right forum? Regards

  • Mac osx Lion for more macs

    I have two macs one have been supplied with Mac osx Lion and the other is some month older and has Snow Leopard installed. May I use the my new macbook with lion to install lion on the other and how it works?