Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Suneeta
webpage
1 Answer(s)      3 years and 11 months ago
Posted in : Java Beginners


java, servlet and JSPs to create a web page with a text box and a button named submit. after submitting i shpuld get a msg successfully added.


Advertisement
View Answers

November 29, 2010 at 4:41 PM


Hi Friend,

Try the following code:

1)form.jsp:

<html>
<form name="form" method="post" action="../Data">
Enter Message: <input type="text" name="msg">
<input type="submit" value="submit">
</form>
</html>

2)Data.java;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;

public class Data extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        String msg=req.getParameter("msg");
        System.out.println(msg);
        try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:student","","");
    Statement stmt=con.createStatement();
    int i=stmt.executeUpdate("insert into data(message) values('"+msg+"')");
    out.println("Message successfully added!");
        con.close();
        } 
        catch(Exception e){
            System.out.println(e);
        }
        }
        }

Thanks



Related Tutorials/Questions & Answers:
webpage
webpage  design a webpage student database using forms and frameset
webpage capture
webpage capture   webpage capture source code using jsps and servlets
Advertisements
copy something from a webpage to my webpage
copy something from a webpage to my webpage  How can I copy something from a webpage to my webpage
make a webpage
make a webpage   I will provide you some basic requirements that you will be implementing over a small web page... Requirements: A web page having... webpage in a different way Try to use features of HTML5, CSS3 and JavaScript
Showing div at the center of the webpage
Showing div at the center of the webpage  Showing div at the center of the webpage
Last modified time of a webpage
Last modified time of a webpage  how can we get the last modified time of a webpage using java
How to print a webpage without url and date in jsp ?
How to print a webpage without url and date in jsp ?  How to print a webpage without url and date in jsp
displaying a physical webpage with frames in iframe
displaying a physical webpage with frames in iframe  i have iframe in my webpage, i have done the coding part for browsing the folders and viewing... sources.i tried to display a sample webpage without frames and it was a success
JSP - Problem of displaying result at webpage
JSP - Problem of displaying result at webpage  Can anyone please help to solve my problem below. My webpage has problem in displaying result position. The result should be display below my title. How do i solve it? Thank you so
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
Login Box appears when a button on the webpage is clicked
Login Box appears when a button on the webpage is clicked  How to create a Login Box on a web page that appears only when a button that is already present on the page is clicked
give me source code of webpage creation using html
give me source code of webpage creation using html  how to create a webpage using html
display resume content in webpage - JSP-Servlet
display resume content in webpage  Hi everbody, I have to display resume(.pdf, .doc,.rtf..txt)file content into a webpage(jsp or html). please i want help like are there any APIs available or any solution?? thank in advance
Page is not getting loaded when I refresh the webpage???
Page is not getting loaded when I refresh the webpage???  **I am loading an image section(image,demo link,Zoom) in a webpage by using javascript function in JSP. It will get all details of image section from database. *I am
Login Box appears at the background of my webpage?
Login Box appears at the background of my webpage?   As per the answer regarding my earlier query, when I post the code in my HTML page, the Login Box appears at the background of my HTMl page...........I tried CSS to change its
Open InternetExplorer Webpage with Java - Java Beginners
Open InternetExplorer Webpage with Java  Hello Sir I want to Open my webpage from swing application when I Click On "VISIT US" Boutton then website will be display How I can Create it on Button Click.  Hi Friend
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
displaying a calendar of only current month in jsp on webpage using javascript
displaying a calendar of only current month in jsp on webpage using javascript  how can we display a calendar of only current month in jsp on webpage using javascript
How to export the table content from an webpage to excel using java?
How to export the table content from an webpage to excel using java?  How to export the table content from an webpage to excel using java? The table contents are generated dynamically in that java page
hi RoseIndia why there is not Fackbook Like button on your webpage?
hi RoseIndia why there is not Fackbook Like button on your webpage?   hi RoseIndia why there is no Fackbook Like button on your webpage? That's the only prob in your problem. Others are excellent
how to display the data from excel to webpage
how to display the data from excel to webpage  Hi, I need help on following I have a webpage contains a text box and a button(get), i give a value in text box such as serial no. like 4024 and by click on get button it should
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java
how to send the content of jtextarea from netbeans IDE to webpage's textarea in java   Hi, i m interested to send the content of my jtextarea which i have developed in netbeans IDE to the webpage's textarea. how can i do
Parent child windows relationships when webpage is accesssed through a hyperlink.
Parent child windows relationships when webpage is accesssed through a hyperlink.  A particular session timeout functionality works when a webpage is loaded. The webpage has parent/child windows. This timeout functionality works
Accessing MS ACCESS databse using a HTML webpage [created using Javascript]
Accessing MS ACCESS databse using a HTML webpage [created using Javascript... pressing the button - 'Submit'. the webpage includes fields like Name, Age, Sex... be displayed in a webpage after click the button - 'show details'. Could you pls help me
Volume setting for webpage flash - Design concepts & design patterns
Volume setting for webpage flash   Hello: I'm glad I found your website. Thank you for the opportunity to ask questions. For months I'v been searching with no success for a way to enter a volume setting for the flash file
How to add google page in my webpage using jquery ajax.
How to add google page in my webpage using jquery ajax.  Hi, I created a page index.html on desktop . this page content following code. <html> </head> <script type="text/javascript" src="http
webpage which client can enter his or her name
webpage which client can enter his or her name   1.if client has entered name he must click on submit button,new webpage should appear which welcome him or her with either one of following messages: "good morning,[name]!","good
webpage which client can enter his or her name
webpage which client can enter his or her name   1.if client has entered name he must click on submit button,new webpage should appear which welcome him or her with either one of following messages: "good morning,[name]!","good
How to find the size of a dynamic webpage using java... eg : Youtube........
How to find the size of a dynamic webpage using java... eg : Youtube........  package newpack; import java.io.BufferedInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL
 

 

 

DMCA.com