Jsp - calling a method form an HTML form inside a jsp

Good mornig everybody,
Does anybody know how to call a Java Method (a public method of a Class) form an Html form that stay in a jsp page.
I'd like to do something like that in myPage.jsp
<%
// Declaration of object
MyObject obj = new MyObject();
%>
<html>
<form action="obj.myMethod()">
<input type=submit vaule=runMethod>
</form>
</html>
Many Tanks
Matteo

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8" import="java.util.*,java.text.*,java.math.*"%>
<jsp:useBean id="p" scope="request" class="com.ecl.web.beans.Bean"/>
<jsp:setProperty name="p" property="*"/>
float t = p.geta(); // (geta() Function in Bean)
do something like this...
create a bean write ur function in that bean...Then call the function in that bean using set and get property...

Similar Messages

  • Calling PLSQL Stored Procedure From HTML Form Submit Button

    Hi there,
    I am having a little difficulty with calling a stored procedure using an html form button. Here is the code I have right now...
    HTP.PRINT('<form action=ZWGKERCF.P_confdelete>');
    HTP.PRINT('<input type=''submit'' value='' Yes '' onClick=''document.getElementById("mypopup").style.display="none"''>');
    HTP.PRINT('</form></div>');Here is the issue - I need to find a way to pass variables to this stored procedure so it know what data to operate on. This stored procedure will delete data for a specific database record and I must pass three variables to this procedure to make it work.
    Lets call them class_number, term, conf These three variables will be passed and the data will be deleted and the person will see a confirmation screen once the delete query has been executed.
    So ideally I would want: ZWGKERCF.P_confdelete(class_number, term, conf) and then the stored procedure would handle the rest!
    Seems pretty simple but I am not sure how to make this happen... My thoughts were:
    Pass the data to this html form (the three fields I need) in hidden variables. Then somehow pass these using POST method to the procedure and read using GET?
    Can someone clarify what the best way to do this is? I have a feeling its something small I am missing - but I would really like some expert insight :-)
    Thanks so much in advance!
    - Jeff

    795018 wrote:
    I am having a little difficulty with calling a stored procedure using an html form button. Here is the code I have right now...
    HTP.PRINT('<form action=ZWGKERCF.P_confdelete>');
    HTP.PRINT('<input type=''submit'' value='' Yes '' onClick=''document.getElementById("mypopup").style.display="none"''>');
    HTP.PRINT('</form></div>');Here is the issue - I need to find a way to pass variables to this stored procedure so it know what data to operate on. This stored procedure will delete data for a specific database record and I must pass three variables to this procedure to make it work. The browser generates a POST or a GET for that form action, that includes all the fields defined in that form. Let's say you define HTML text input fields name and surname for the form. The URL generated for that form's submission will be:
    http://../ZWGKERCF.P_confdelete?name=value1&surname=value2The browser therefore submits the values of the form as part of the URL.
    The web server receives this. It sees that the base URL (aka location) is serviced by Oracle's mod_plsql. It passes the URL to this module. This module builds a PL/SQL block and makes the call to Oracle. If we ignore the additional calls it makes (setting up an OWA environment for that Oracle session), this is how the call to Oracle basically looks like:
    begin
      ZWGKERCF.P_confdelete( name=> :value1, surname =>  :value2 );
    end;Thus the PL/SQL web enabled procedure gets all the input fields from the HTML form, via its parameter signature. As you can define parameter values with defaults, you can support variable parameter calls. For example, let's say our procedure also have a birthDate parameter that is default null. The above call will still work (from a HTML form that does not have a date field). And so will the following URL and call that includes a birth date:
    URL:
    http://../ZWGKERCF.P_confdelete?name=value1&surname=value2&birthdate=2000/01/01
    PL/SQL call:
    begin
      ZWGKERCF.P_confdelete( name=> :value1, surname =>  :value2, birthdate => :value3 );
    end;There is also another call method you can use - the flexible 2 parameter interface. In this case the PL/SQL procedure name in the URL is suffixed with an exclamation mark. This instructs the mod_plsql module to put all input field names it received from the web browser into a string array. And put all the values for those fields in another string array. Then it calls your procedure with these arrays as input.
    Your procedure therefore has a fixed parameter signature. Two parameters only. Both are string arrays.
    The advantage of this method is that your procedure can dynamically deal with the web browser's input - any number of fields. The procedure's signature no longer needs to match the HTML form's signature.
    You can also defined RESTful mod_plsql calls to PL/SQL. In which case the call format from the web browser looks different and is handled differently by mod_plsql.
    All this (and more) is detailed in the Oracle manuals dealing with mod_plsql - have a search via http://tahiti.oracle.com (Oracle Documentation Portal) for the relevant manuals for the Oracle version you are using.
    Alternatively, simply download and install Oracle Apex (Application Express). This is a web development and run-time framework and do all the complexities for you - including web state management, optimistic locking, security and so on.

  • Calling a method with a html Submit button

    hi guys,
    is it possible to call a method from a JSP file using a HTML submit button. I know i can call another website easily doing it this way, is there a similar way available to call a method once the button is clicked?
    FYI
    The method is in a bean file named jdbc. The methods name is getUsername.
    Nice one.
    <form action = <%jdbc.getUsername()%> <input type="submit" value="Submit">

    Dear friend,
    you mentioned that u need to call a method when submit button is clicked. Is the method dynamically created. If not so, then you can include the method on the submit button html file itself.
    Regards,
    Rengaraj.R

  • Calling a method within a class form another class(ViewController)

    I am creating an SQL project in XCODE. I have one view. My main view controller is loading the database to a table/array. I want to add another class (with no NIB) just to handle the display of the table in a UITableView. So, I added a skeleton cocoa touch class file to my classes folder to handle this function when parameters change.
    So, in my app delegate, the "applicationdidFinishLaunchingWithOptions" method loads my mainViewController and NIB.  On the "viewDidLoad" method in my mainViewController, I read a URL into an SQLite database and close the database.  Herein lies the problem: I want to call my new class (TableViewHandler) and pass it the array created in the mainViewController and use the array to populate the UITable.
    How do I call a class from within another class (which has no NIB) to populate the table?  Especially if my TableViewHandler has no "viewDidLoad", "viewDidAppear", etc.
    Regads,
    -Kevin

    This is what my exact problem.
    i've created a bean (DataBean) to access the database. i'm having a servlet program (ShopBook). now to check some details over there in the database from the servlet i'm in need to use a method in the DataBean.
    both ShopBook.java and DataBean.java lies in the package shoppack.
    in ShopBook i tried to instantiate the object to DataBean as
    DataBean db = new DataBean();
    it shows the compiler error, unable to resolve symbol DataBean.
    note:
    first i compiled DataBean.java, it got compiled perfectly and the class file resides inside the shoppack.
    when i'm trying to compile the ShopBook its telling this error.
    hope i'm clear in explaining my problem. can u please help me?
    thank u in advance.
    regards,
    Fazli

  • Fill a PDF form from HTML form

    I Have a HTML inquiry form that print a PDF form. I don't know how to pass the fields vars in my HTML to PDF vars

    you can see de app in www.karakol.es
    is a jquery interface and javascript program
    At the end of section 4, once filled out the form the user opens the PDF form with form fields listed.
    The user prints the PDF opened by any printer or save the PDF to mail
    Before open the PDF the data colected are sent to a server.
    Of course you can call a saved form an display in the user interface

  • Help : Calling a Servlet.doPost from a HTML Form (404 Error !!!)

    All
    I trying to make a call to a doPost method of a servlet from the doGet method of the same servlet.
    The call is made from an HTML form, so
    *<form name="input" action="servlet/deleteAlertPage" method="post">*
    ======================================================================
    The web.xml file entry is as follows:
    *<servlet>*
    *<servlet-name>deleteAlertPage</servlet-name>*
    *<servlet-class>bsp.perceptive.custom.webapp.deleteAlert.deleteAlertPage</servlet-class>*
    *<load-on-startup>0</load-on-startup>*
    *</servlet>*
    *<servlet-mapping>*
    *<servlet-name>deleteAlertPage</servlet-name>*
    *<url-pattern>/deleteAlertPage</url-pattern>*
    *</servlet-mapping>*
    So when I run my Servlet from my JDeveloper, I do see the “doGet” method getting executed successfully and I see my HTML from appearing on a browser page.
    As soon as I press the submit button, where I want the “doPost” method to get executed, I get the following error:
    Error 404--Not Found
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    *10.4.5 404 Not Found*
    The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
    If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead.
    The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource
    is permanently unavailable and has no forwarding address.
    Any ideas ? Is my Servlet Setup and Execution Correct ?
    Any help is appreciated.
    My JDeveloper Version is the latest release :
    About
    Oracle JDeveloper 11g Release 1 11.1.1.2.0
    Studio Edition Version 11.1.1.2.0
    Build JDEVADF_11.1.1.2.0_GENERIC_091029.2229.5536
    Copyright © 1997, 2009 Oracle and/or its affiliates. All rights reserved.
    IDE Version: 11.1.1.2.36.55.36
    Product ID: oracle.jdeveloper
    Product Version: 11.1.1.2.36.55.36
    Any help and advice is greatly appreciated.
    Regards
    patrice

    John
    I got it to work !!
    I had to place the application name in the action value also I had to change the port number, from 8080 to be 7101.
    However
    It was not that straight forward, because when I created my web Application I gave it the application Name of "BSPCustPerWebApps" and Project Name of "BSPCustPerWebApps"and this is reflected in my JDeveloper folder structure: "....\mywork\BSPCustPerWebApps\BSPCustPerWebApps\src\bsp\perceptive\custom\webapp\deleteAlert"
    now when I run my Servlet initially I noticed that Browser URL is saying : http://localhost:7101/BSPCustPerWebApps-BSPCustPerWebApps-context-root/deleteAlertPage
    which means that the web application is : BSPCustPerWebApps-BSPCustPerWebApps-context-root
    so I changed my action value to be
    action="http://localhost:7101/BSPCustPerWebApps-BSPCustPerWebApps-context-root/deleteAlertPage"
    and that worked.
    Weblogic must have created/defauled the application name using the application name and project name that I gave duriung the servlet creation.
    Is there a way of changing the application name to be something shorter and more meaningfull ?
    Also I did not want to hard code the server name, port etc in the action value, so again is there way of making this to be derived ?
    Do you know how to access the WebLogic Console ? , considering I have only installed JDev, which has an embedded weblogic server.
    Thanks for your help.

  • Create Form Beans from JSP/HTML forms

    In the Builder certification objectives, there is one called "Create Form Beans from JSP/HTML forms". How can I do that? How can I create a form beam starting from the JSP form or HTML form?

    Guys, no one from forum can answer this question?

  • How to call a method of an Action class from JSP on load?

    Hi guys
    Due to bad design pattern, i am forced to do something which i have not tried before.
    I need to call a method of a struts action class which invalidated the user session FROM the JSP itself on load. Which means it would not require user input.
    We have a subclass of a DispatchAction that handles all the incoming .dos.
    So http://blarblarblar:7001/blar/blar/doSomething.do?method=logout will dispatch to an Action class called DoSomething, into a method called logout().
    So when the webapp throws an exception, the ActionMapping actually displays an error.jsp and i have to invalidate the user at this stage.
    I can't change the most top level code in the base action class so i got to do it this way.
    Any help is much appreciated.
    Thanks.

    hi :-) DispatchAction is quite cool ;-)
    dont get much of your question but hope
    the suggestion below could help.
    A. use redirect?
    or
    B. autosubmit the form
    1. create your form in a jsp
       <html:form action="/doSomething" />
         <html:hidden name="method" value="logout" />
       </html:form>2. auto submit the form with method = logout
    put the function autosubmit in the "onLoad" event of the body
       <script>
         function autosubmit(){
         var form = document.yourformname;
         form.submit();
       <script>regards,

  • Solved: process POST from html form

    Hello,
    I have the next question, I have a public website (in an other technology) that uses the "POST" method of an html form to navigate to my application.
    One of the fields on the html form is the field "name".
    I was wondering if their is any possibility to get the value of the field "name" when I come on my ApEx page?
    I hope i'm making some sense here.
    Thanks in advance
    Kind regards,
    Oli

    Perhaps this will help....
    http://htmldb.oracle.com/pls/otn/f?p=9487:65
    Run the demo and try the view_http_post_flex_redirect procedure call.

  • Save pdf form as a html form

    Hi everybody,
    I have a form which I just made in Adobe Acrobat pro XI (Windows 7 Professional N 64bit). I would like to save it as an HTML form (or at least users should be able to open it directly in browser and fill it out - saving it is NOT necessary).
    I tried so far:
    1. FILE --> SAVE AS OTHERS --> HTML WEB PAGE
    but it actually kind of prints the pdf form as image, which should not happen. Text ist also scrambled across the page without meaning.
    2. converting it online to HTML but the buttons disappear. Text is in the right place but no buttons (radio buttons for ex. or text field).
    Is there a way to "convert" the pdf form to html "form"? And if yes, how can I do it?
    Thank you very much.

    I create HTML forms by hand coding, so I cannot recommend any specific apps. Most now suffer from being too complicated.
    I think you need to forget the idea of converting a PDF form (nicely laid out, attractive) to a similar HTML forms. HTML forms are basic, functional, ugly and do not have a fixed layout. A conversion tool will not magically overcome this limitation.

  • Uix:dateField inside struts html:form

    this renders calendar:
    <uix:form name="f8">
    <uix:dateField name="e2" />
    </uix:form>
    this not:
    <html:form styleId="f3" action="showsth.do">
    <uix:dateField name="e2" />
    </html:form>
    where html:form is struts form
    why?
    what am I doing wrong?
    I thing use uix and struts together would be amazing but ...

    Unfortunately, we do not support uix elements inside struts form element.

  • Jsp calling a function in js -- object expected runtime error

    Hi,
    I have a js file. script.js
    *function popup( url ) {*
    newWin=window.open(url,'popupWindow,resizable=yes,menubar=no,status=no,toolbar=no,scrollbars=yes');
    newWin.focus();
    void(0);
    and a jsp calling the function in js
    *<HTML>*
    *<HEAD>*
    *<SCRIPT>*
    *<jsp:include page="script.js"/>*
    *</SCRIPT>*
    *</HEAD>*
    *<BODY onLoad="javascript:popup('http;//www.google.com');">*
    *</BODY>*
    *</HTML>*
    Now when i execute the jsp, it gives runtime error -> object expected..
    Not able to figure out why this occurs.. am I doing it the right way ?

    Do you think is this the right way to include .js file...
    <SCRIPT>
    <jsp:include page="script.js"/>
    </SCRIPT>I generally do this way...
    <head>
    <script language="javascript" src = "script.js">
    </script>
    </head>

  • SAPEVENT - Calling a method

    Hello everyone,
    I am trying to call a method from my HTML and I need to pass my method some parameters from my HTML page.(my HTML page is rendered by XSLT and displayed in the CustomerFactSheet tab/HTML control in CIC) .
    Currently, I use the SAPEVENT, which allows me to pass the BP number successfully.
    Can anyone tell me how to pass other parameters (such as begin and end dates) in my SAPEVENT; or suggest another better way to call a method from the HTML code in the HTML control?
    Cheers,
    Tania

    Hello Vijaya,
    Thanks for the reply, but this doesn't solve the problem.
    The HTML Viewer is in SAP WinGui and not in a PCUI application.
    As far as I can see it, the problem simply lies in the SAPEVENT Handler in HTML Viewrer; it only supports 4 parameters:
    - OBJECTTYPE
    - OBJECTID
    - LOGYSYS
    - CALLERID
    What if one needs to pass another parameter?
    Can anyone recomend links/documentation around this topic (SAPEVENT, Context Menu)?
    Cheers,
    Tania

  • JSP invoked method inside onclick property of html form

    I have an html form with an action to itself. I'm using javabeans with jsp to hold a list of strings. I want to click a button on the html form and have it add to the list of strings. however, if I put onclick="<% mybean.addString("sample") %>" inside the button's tag, it executes the code every time I load the page, instead of only when the button is pressed. What do I have wrong here, and what's the code to fix it?

    jobocop17 wrote:
    What do I have wrong here, and You have misunderstood how web application works. Basically, server side code(jsp scriptlets, custom tags etc) get processed in server and the processed results are sent to client side where the client side code(eg: javascript) get executed. Following jsp code
      <% mybean.addString("sample") %>is processed in server and the browser will only get its result which is what you have noticed and which is how it works.
    what's the code to fix it?Use either clientside scripting or make a server call to get it done on serverside.

  • JSP part of HTML form

    i have an html form (part of code included below) and don't know how to write the JSP for the results page. I want to be able to click "submit" and have the inputed information placed in a text file and saved in the same folder as my HTML files. I am new to JSP and am trying to learn. thanks in advance.
    code:
    <html>
    <head>
    <title>Form</title>
    </head>
    <form name="input" action="html_form_action.asp" method="get" >
    Model Name:
    <br>
    <input type="text" name="modelname">
    <br>
    Lenght Unit:
    <br>
    <input type="text" name="lenghtunit">
    <br>
    <br>
    <TEXTAREA ROWS="5" COLS="50">

    You need to learn some java first. Then learn a bit about JSP. It isn't like classic ASP.
    Then write a java class that takes arguments and writes them to a file. It will be good practice for making the full bean. :)
    When you're comfortable with the class and it does what you want (writes things to a file), make the class a bean (use a package) and make the arguments be gettable and settable properties and have a method do the write using those properties (instead of main doing it).
    Put the bean in a JSP and set the properties and call the method that writes them to a file.
    If you can't follow that, you're not ready to write it. Go, read, learn more about java and java beans, and come back to this.
    Note that you may have permissions problems if the directory the class writes to is not writable by the user that the web server runs as.
    Note on your html page: you should be targetting a JSP page, not ASP, and you should be using POST, not GET, as the method.
    HTH

Maybe you are looking for

  • Issue with SSIS Custom Components - 64 bit SQL 2012

    Hello All, Our SSIS packages built on SQL 2008 R2 make use of some custom components. These custom components are installed as part of an MSI. The dll's are copied over to the Windows/assemble [GAC Folder] and also to the Program Files(x86)/SQL Serve

  • Java VM Error EXCEPTION_ACCESS_VIOLATION (0xc0000005) when using drawImage

    I'm getting a strange VM error on my program. I have a BufferedImage object, and I call its createGraphics() method to get the Graphics2D context. When I call drawImage on that object, sometimes I get this error. The error log file is below. This hap

  • Paypal authorized or not?

    I recently put in an order online for a desktop computer and proceded to check out with Paypal. There was an error and the website stated that it "failed to authorize payment". However, I recieved a confirmation email from PayPal stating that the pay

  • Http server error while installing 11.5.5 on winNT4.0 sp6

    while installing 11.5.5 on winNT4.0 sp6 The servername is BIGPIG. while installing oracle Apps it asks the DNS domain name I gave it as 'localhost'. It allocates port no. 8001 for this. Now if I open internet browser with http://bigpig.localhost:8001

  • Rendering clips

    I have made several movie/slideshows and have never had any problems. All of a sudden, after my children have been using it, I can not successfully make a movie with photographs. I started to create a new movie, and when I went to save it, it says th