Insert from button in jsp page

hi, im new o jso and needto make an insert frim a jsp page with a button,
what should i do?
i made a javascript function but i really dont know if am i right and then i tried to call this function from the html tag
beside this i execute de query from java and it was success!!, but i dont know what is wrong when i try from the jsp page with de button, please help!
thx!
here it's my code:
<script type="text/javascript">
import java.sql.*;
function Agregar()
return
StringBuffer sb = new StringBuffer();
try{
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Prueba","postgres","hola");
Statement stmt = conn.createStatement();
stmt.executeUpdate("INSERT INTO tbl_responsable (cedula,nombre,direccion) VALUES (14021752,'carlos','caracas')");
}catch(Exception e){
System.out.println("EXPLOTO");
</script>
ahora en el html que debo hacer??, o si tengo q hacer otra cosa???
html del boton:
<input type="submit" value="Agregar" action="Agregar()">
what should i do, what its wrong??
thx again!

try this
<input type="submit" onclick=" return Agregar();">
or
<input type="submit" onclick=" Agregar();">

Similar Messages

  • I have a button in JSP page inside an UIWebView by pressing the button i want to run another existing iPhone native application in background only.Do anyone have a solution for this.

    I have a button in JSP page inside an UIWebView by pressing the button i want to run another
    existing iPhone native application in background only.Do anyone have a solution for this.

    Sounds like a virus.... I hope it's not...
    Launching Other Apps within an iPhone

  • Message bundles accessed from JSF and JSP pages

    Hello, everybody!
    I'm developing a localized JSF application. It is working pretty well until now.
    These are my message files:
    mensagens.properties
    mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
    <application>
        <resource-bundle>
            <base-name>br.urca.www.biblioteca.web.mensagens</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>And this is how I access the messages in a page:
    <h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
    my web application. This page is displaying ok but I also need to access the
    message bundles as I'm able to access in the normal jsp with the JSF components.
    As you should know I can't use something like the above code with an +<h:outputText>+
    to access the messages because this is a JSF component and I'll not be able to use
    JSF components with this raw jsp page.
    So, my question is: how do I access my localized messages from a raw jsp page? I
    suppose there should be a way to do this, but unfortunately I started programming
    to the web world in Java with JSF, not JSP, so I don't know how to do this with
    JSP.
    Thank you very much.
    Marcos

    BalusC wrote:
    Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
    Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
    Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
    I have this component:
    <h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
        valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
        <f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
    </h:selectOneMenu>that calls this event in my backing bean class:
    public void idiomaAplicacaoMudado(ValueChangeEvent e)
        fIdiomaAplicacao.liberarItens();
        Idioma idioma = Idioma.deString(e.getNewValue().toString());
        // This line is for JSF
        FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
        // This line is for Tiles
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
            put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
    }So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
    Thank you.
    Marcos

  • Connecting to Servlet from a Login JSP page

    Hi Everyone can anyone tell how to invoke a Servlet say DBHandler servlet from a Login JSP page
    I am using JRun3.0
    If i do this i am getting an error Error 405 Resource not allowed
    The directory structure is as follows :::-----
    emtech\jsp\Login.jsp
    emtech\web-inf\classes\DBHandler.java
    in my Login.jsp page i am giving
    <form method="post" action ="DBHandler">
    </form>
    Help will be highly appreciated
    Thanking in advance
    Mumtaz
    India

    Hi
    Even after modifying i am getting the same problem
    if i use jsp:forward tag then it works fine ie transfers control fully to the servlet but if i set the form action
    like /servlet/LoginServlet or LoginServlet i get this in my url ---http://localhost:8100/emtech2/jsp/emtech2/servlet/LoginServlet
    i just am thinking of using JRun
    Plz help
    Thanking You

  • To search a record from the table by providing a search button in JSP page

    Hi,
    My problem statement is:
    I have a jsp page which displays a table containing records. I have to provide a button called search and a condition in a textfield so that the record which matches the condition gets highlighted.
    Can anyone solve my problem statement. Its urgent.
    Suraj.

    Example:
    on the jsp page, read the matched value the server provides and use it to put the statement in bold using the <b> tag (I dont know the syntax for highlighting).
    <%String matchedString=(String) request.getAttribute("matchingString");%>
    Then in your list:
    <%if(matchedString.compareTo(thisRecordString)==0){%>
    <b>
    <%}%>
    //your text goes here
    <%if(matchedString.compareTo(thisRecordString)==0){%>
    </b>
    <%}%>

  • Print Button on JSP page prints title,time etc

    Hi I have aprint Button on my jsp page which prints whatever I want selectively using the <style tags>
    <style type="text/css" media=print>
    .noprint { display: none}
    .noscreen { color: black }
    </style>
    <style type="text/css" media=screen>
    .noscreen { display: none}
    .noprint { color: blue }
    </style>
    <SCRIPT Language="Javascript">
    function printit(){
    window.print();
    </SCRIPT>
    My print Button calls the JavaScript and prints everything that does not have a class=noprint in it... When I print however it also prints on the page
    -The Title on the Left Top corner
    - Page 1 of 1 on RIGHT TOP
    - 2/13/03 on Left bottom
    - 4:06 thats the time on the RIGHT BOTTOM
    Is there anyway I can prevent it from printing this?

    These probably come from the browser. Check if your browser is configured to print these on every page that is printed. If so, you can turn these of from the browser's Page Setup dialog.

  • Passing value from JApplet to Jsp page

    Hello,
    How can i pass a value that is entered in a JTextArea in a JApplet and fetch the entered value from JTextArea and display it in a JSP page.
    It would be kindful if someone could help me with this problem.
    Regards
    Sanam

    hello,
    Thanks for ur reply,
    Sorry to say that i did not understand where to implement ur code in my code.
    Below is my code could u plz tell me where do i put in ur code.
    My code works fine u can compile it.
    javac *.java;
    appletviewer BIA.java
    Can u plz tell the JSP code.
    It would be very kindful if u could please help me.
    Thank you
    //**************** BIA.java***********
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    <applet code = "BIA" width = 500 height = 500>
    </applet>
    public class BIA extends JApplet
         public static Container cp;
         public BIAP panel;     
         public TB action;
         public void init()
              panel = new BIAP();
              action = new TB(panel);
              action.setLayout(new GridLayout(2,2));     
              cp = getContentPane();
              cp.setLayout(new BorderLayout());
              cp.add(action, "North");
              cp.add(new JScrollPane(panel));
              repaint();
    //******************* BIAP.java*************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;     
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.lang.reflect.Field;
    class BIAP extends JPanel
         public BIA bia;
         public BufferedImage image;
         public double scale, scaleInc;
         public JTextArea jt;
         public BIAP()
              loadImage();
              setBackground(Color.white);
              scale = 1.0;
              scaleInc = 0.01;
              setLayout(null);
              jt = new JTextArea("Welcome");
              jt.setBounds(0,0, 90,30);
              add(jt);     
              repaint();
         protected void paintComponent(Graphics g)
              super.paintComponent(g);
                   Graphics2D g2 = (Graphics2D)g;
              g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                        RenderingHints.VALUE_INTERPOLATION_BICUBIC);
              int w = getWidth();
              int h = getHeight();
              int imageWidth = image.getWidth();
              int imageHeight = image.getHeight();
              int x = (w - imageWidth)/2;
              int y = (h - imageHeight)/2;
              g2.drawImage(image, x, y, this);
         private void loadImage()
              String fileName = "Terragen___Losing_Grip_by_Blackheart6004.jpg";
              try
              URL url = getClass().getResource(fileName);
              System.out.println(url);
              image = ImageIO.read(url);
              catch(MalformedURLException mue)
              System.out.println("url: " + mue.getMessage());
              catch(IOException ioe)
              System.out.println("read: " + ioe.getMessage());
         public Dimension getPreferredSize()
              Dimension d = new Dimension();
              d.width = (int)(scale * image.getWidth());
              d.height = (int)(scale * image.getHeight());
              return d;
         //method used for Zoom Operation
         public void setScale (int inc)
              scale += inc * scaleInc;
              revalidate();
              repaint();
    //************************** TB*********************
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import java.util.Vector;     
    import java.applet.*;
    import java.awt.image.*;
    import javax.swing.*;
    import javax.swing.event.*;
    class TB extends JPanel
         BIAP panel;
         JButton save = new JButton("Save");
         public TB(BIAP biap)
              panel = biap;
              ActionListener sa = new ActionListener()
                   public void actionPerformed(ActionEvent e)          
                        JButton button = (JButton)e.getSource();
                        if(button == save)
                             //panel.fileSave();
              save.addActionListener(sa);
              add(save);
    }

  • Multiple buttons in jsp page

    Hi to all
    afteradminlogin.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
          <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <h4>Select your Department</h4>
    <br>
    <html:link forward="adminbooks">Java</html:link>
    <br>
    <br>
    <html:link forward="adminbooks">.Net</html:link>
    </body>
    </html>in this page when we click on java link it has to move to the adminbooks .but it is not moving it is showing empty page in that place
    adminbooks.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
          <%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <input type="hidden" name="method">
    <h4>Welcome To Selection</h4>
    <table border="1">
    <tr>
    <th>
    sno
    </th>
    <th>
    Book Name
    </th>
    <th>
    Author
    </th>
    <th>
    Available No.of Books
    </th>
    <th>
    Select
    </th>
    </tr>
    </table>
    <html:submit name="add" value="add" >Add</html:submit>
    <html:submit name="edit" value="edit">Edit</html:submit>
    </body>
    </html>in this above jsp page i am using two buttons .in this page when we click on add button it has to go to another page and after submit that page that data has to add the the above table how can done that one
    where add button jsp page
    adminaddbooks.jsp:--
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
        %@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
    <%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <br>
    Book Name <input type="text" name="bookname">
    <br>
    <br>
    Author <input type="text"  name="author">
    <br>
    <br>
    Available No.of Books <input type="text" name="availablebooks">
    <br>
    <br>
    <input type="submit"  value="submit" name="submit">
    </body>
    </html>strutsconfig.xml:--
    <struts-config>
        <form-beans>
        <form-bean
               name="AdminForm"
               type="org.struts.library.admin.AdminForm">
    </form-beans>
    <global-forwards>
    <forward   
                     name="userlogin"
                     path="/Logon.do"/>
            <forward
                     name="adminlogin"
                     path="/adminlogin.do"/>   
           <forward name="adminbooks"
                    path="/adminbooks.do"/>         
            <forward
                name="home"
                path="/home.do"/>
        </global-forwards>
    <action-mappings>
    <action
             path="/adminlogin"
             forward="/pages/adminlogin.jsp"/>
             <action
                  path="/adminaction"
                  type="org.struts.library.admin.AdminAction"
                  name="AdminForm"
                  scope="request"
                  validate="true"
                  input="/pages/adminlogin.jsp">
             <forward   name="success"
                        path="/pages/afteradminlogin.jsp"/>
             <forward    name="failure"
                         path="/pages/adminlogin.jsp"/>
                         </action>        
                  <action path="/adminbooks"
                         type="org.struts.library.admin.AdminBooksAction"
                        forward="/pages/adminbooks.jsp">
                  <forward name="add"
                          path="/pages/adminaddbooks.jsp"/>
                  <forward name="edit"
                           path="/pages/admineditbooks"/>
                         </action>                           
                  </struts-config>

    if you link to an action doesnt work then maybe your action is wrong but you didnt post it.
    You cannot submit a form if you dont use a form in your code
    Other general advice:
    Study Struts better and make sure you know HTML/JSP
    Get an example running and then start with a simple "Hello Struts" test with an Action that doesnt do much

  • How to set the HOME link from two frame jsp page to no frame main page?

    Hi all,
    i have one main jsp page named as main.jsp.
    From the main.jsp, i can click the button and link to the twoFrame.jsp.
    This twoFrame.jsp have another two different jsp inside the frame called Aframe.jsp and Bframe.jsp.
    i try to put HOME in the Aframe.jsp(one of the page inside twoFrame.jsp) but only the Aframe.jsp manage to link to main.jsp but the Bframe still there.
    My question is: How to set the HOME link button from this twoFrame.jsp to the main.jsp? what i want is from twoFrame.jsp(two frame) to main.jsp(no frame).
    rgds,
    Bryan523

    No offense, but this is basic HTML. You shuold look into learning HTML before getting too deep into JSP. Try this: http://www.w3schools.com/html/default.asp
    But as a more specific answer, you have to set a target for the link to the _parent of your frame:
    <a href="main.jsp" target="_parent">Home</a>

  • Call java method from button in UIX page

    Greetings,
    I want to call a java method from a button on a uix page.
    Does it have to be a submit button or it maybe a simple button.
    If it was from a JSP page, it would be a much more different process ?
    This method should delete a row from another view (View2).
    delete from tableB ta where ta.field1 = &1
    My question is how do I build the method to delete a row and how do I invoke the method using the button ?
    Thanks

    This sounds like a JDeveloper/ADF issue that is not related to JHeadstart. Can you please log a TAR at MetaLink ( http://metalink.oracle.com/ ), or ask this question at the JDeveloper forum at http://otn.oracle.com/discussionforums/jdev.html ?
    Thanks,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting

  • Display values from database in jsp page

    Hi,
    I need to display a list of options with checkboxes in a jsp page .The values are retrived from DB.
    formBean fb=new FormBean(request)
    <Input type="checkbox" name="xyz" value="<%=fb.getFormdata( "xyz")%>">
    should this"xyz" be the name of the column in the DB table?

    This is my FormBean
    public class FormBean {
    HttpServletRequest _request;
    public FormBean(HttpServletRequest request) {
    _request = request;
    public String getFormData(String abc) {
    return getFormData(abc, true);
    public String getFormData(String name, boolean filter) {
    String value = null;
    if (_request != null) {
    value = _request.getParameter(abc);
    if (value == null) value = "";
    if (filter) {
    value = Utils.filter(value);
    return value;
    * "Clears" parameters. Useful if you do wnat a form initialized with blanks rather than
    * current values;
    public void clear() {
    _request = null;
    }

  • How to call a concurrent program from a Custom JSP page.

    Hi,
    I have a custom JSP page which i have deployed by creating a form function with the path of the JSP Page
    and added the JSP Page to the OA_HTML top.
    Now, i need to call a concurrent program from the JSP Page, i have all the parameters in my page and i am using the standard class as below:
    ConcurrentRequest cr= new ConcurrentRequest(con);
    int requestId= cr.submitRequest("XXINV",programName,null,null,false,vec);
    I have verified my connection object and it is OK but i am getting the exception that user is not set to run the program.
    I tried the below code in my JSP page and getting -1 for all test variables :-
    int userId = wctx.getUserId();
    int respApplId = wctx.getRespApplId();
    int respId = wctx.getRespId();
    I think i need to set the context in JSP page to run the program..
    Pls help ....
    Regards
    Saurabh Jaiswal

    Hi,
    Thanks for the reply,,,
    This is a possible solution but this will allow to run the program anyhow.
    But the procedure which i call thru callable statement will start with
    fnd_global.apps_initialize (3825, 50603, 704);
    fnd_request.submit_request API call.
    Now, the values of user and Responsibilty is required in the program and it changes.
    With this approach we have to hardcode the user and resp.
    The same JSP page is attached to other responsibilities and there the concurrent program would get fired as if fired from the resp Id hardcoded as above.
    Need to capture user Id and RespId.
    How can i set the apps Context in JSP page???
    Regards
    Saurabh Jaiswal

  • Database query ResultSet from servlet to JSP page

              Hi there,
              I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.
              I would like to know if it is possible for me to use a Servlet to search the
              database (I know this bit is possible!), but then I would like the servlet to
              forward to a jsp page which will then display the ResultSet that the servlet has
              retrieved, i.e. when forwarding from a servlet to a jsp, is it possible for the
              jsp page to have access to the servlet's data? I know that it gets access to
              the response and request objects, but what about a ResultSet?
              Sorry it this sounds a little silly - i am a bit of a newbie.
              Thanks in advance for your help,
              SJ
              

    HttpServletRequest.setAttribute let's you share data for a particular
              request. When you call forward you can store the resultset in the request.
              Make sure your JSP does close the result set though, because what you are
              trying to do doesn't sound good :)
              If you want to share data across the session, take a look at the HttpSession
              object.
              read through the servlet specification, it is fairly easy to read and will
              give you all the info you need
              Filip
              ~
              Namaste - I bow to the divine in you
              ~
              Filip Hanik
              Software Architect
              [email protected]
              www.filip.net
              "SJ" <[email protected]> wrote in message
              news:[email protected]...
              >
              > Hi there,
              >
              > I have an Access 2000 database. I am running Apache and Tomcat on Windows
              Me.
              > I would like to know if it is possible for me to use a Servlet to search
              the
              > database (I know this bit is possible!), but then I would like the servlet
              to
              > forward to a jsp page which will then display the ResultSet that the
              servlet has
              > retrieved, i.e. when forwarding from a servlet to a jsp, is it possible
              for the
              > jsp page to have access to the servlet's data? I know that it gets access
              to
              > the response and request objects, but what about a ResultSet?
              >
              > Sorry it this sounds a little silly - i am a bit of a newbie.
              >
              > Thanks in advance for your help,
              >
              > SJ
              

  • How to save data in html format while user click a save button in jsp page

    Hi All,
    I have the following requirement
    If user click on the Save Button it should display a window which allows the user to select the directory and the data is stored in the Internet Explorer Format.
    Could please anybody suggest me how to impletment the above requirment in jsp page.
    It's very urgent. Please replay ASAP.
    Thanks
    Rajeshwari

    Analyzing ur ques ...
    If user click on the Save Button it should display a window which allows the user to select the directory and the data is stored in the Internet Explorer Format.hmmm..
    There is no html object type which supports directory selection for download. There is only an input type="file" which however is related to an upload scenario.
    By downloading the file using output stream u can achieve what you want.
    You simply need to do the following things ..
    a) Write to an output stream
    b) Set the content type to "text/html" for your response
    Example ....
    response.setContentType("text/html");
    response.setHeader("Content-disposition",
    "attachment; filename" +
    "Example.html" );
    javax.servlet.ServletOutputStream stream = res.getOutputStream();
    StringBuffer text = new StringBuffer(1024);
    text.append("some text . . . ");
    text.append("more text . . . ");
    stream.write(data);
    stream.close();

  • Tab Button in JSP page using Jdeveloper

    Hi Guys
    I have a basic question, In Jdeveloper I am creating a JSP page. I need to have Tab buttons in that page, but i am not able to locate the tab buttons, I wanted to know that do Jdeveloper provides the facility for tab buttons, if it does, where can i find the tab button on the Jdeveloper.
    regards

    Yes, it is possible. But you must use ADF Faces technology. There is component called ShowOneTab.
    e.g.:
              <af:showOneTab position="above">
                <af:showDetailItem text="showDetailItem 1">
                  <af:inputText label="Label 1"/>
                </af:showDetailItem>
                <af:showDetailItem text="showDetailItem 2">
                  <af:inputText label="Label 1"/>
                </af:showDetailItem>
              </af:showOneTab>regards,
    Branislav

Maybe you are looking for