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




Have Programming Question? Ask it here!
 
 
 


srikanthkumar
jsp and java
1 Answer(s)      3 years and 6 months ago
Posted in : JSP-Servlet


how to write a jsp and related java code to enter student marks into database


Advertisement
View Answers

February 4, 2011 at 12:15 PM


Hi Friend,

Try the following code:

1)insert.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="../InsertServlet">
<table>
<tr><td>Name:</td><td><input type="text" name="name"></td></tr>
<tr><td>Marks:</td><td><input type="text" name="marks"></td></tr>
<tr><td></td><td><input type="submit" value="Submit"></td></tr>
</table>
</form>
</html>

2)InsertServlet.java:

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

public class InsertServlet extends HttpServlet { 
    public void doPost(HttpServletRequest req,HttpServletResponse res) throws ServletException,IOException {
        res.setContentType("text/html");
        PrintWriter out = res.getWriter();
        String name=req.getParameter("name");
        String marks=req.getParameter("marks");
        int mm=Integer.parseInt(marks);
try{
Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           int i=st.executeUpdate("insert into student(name,marks) values('"+name+"',"+mm+")");
         out.println("Data is inserted successfully");
         con.close();
        }
catch(Exception e){
    System.out.println(e);
}
            }
        }

Thanks



Related Tutorials/Questions & Answers:
Java jsp
Java jsp  What is JSP
jsp and java
jsp and java  how to write a jsp and related java code to enter student marks into database
Advertisements
java - jsp
java - jsp  program to view and update employee name using JSP without database
java/jsp
java/jsp  In a JSP program called books.jsp, the Java code out.print(request.getParameter(‚??number‚??)); displays "1111111‚??. What are the possible ways for the parameter number to have got its value
java jsp - JSP-Servlet
java jsp  i have a jsp file, in that i am uploading a file, after uploading the file had to display in the screen. it is displaying if only i refresh the page. but i want to display the uploaded file without refreshing the page
Java from JSP - JSP-Servlet
Calling Java from JSP  Does anyone have an example of Calling Java from JSP
JSP with java/servlet - JSP-Servlet
JSP with java/servlet  Thanks Deepak for your answere to my previous question. With reference to my previous question about JSP populate, actually I... (java bean or servlet) to fecth the database. Jsp would get the data from
JAVA JSP and Servlet - JSP-Servlet
JAVA JSP and Servlet  for sending mail through lan without intenet and also chatting facility for online users using Java JSP & SERVLET code.  Hi Friend, Please visit the following links: http://www.roseindia.net
multiuser in java/jsp? - JSP-Servlet
multiuser in java/jsp?  Hi!!! Rose India Team, Kindly let me know what is exact meaning of multiuser in java? I made an web application using jsp... friend, Multi User in Jsp : More then one User can access in Web appication
java jsp
java jsp  it is : javax.servlet.jsp only but getting error wt is reason?   Use javax.servlet.jsp.* in your code
java jsp
java jsp  please I want code to parse a web page using Dom parser, thanks
JAVA,JSP,SERVELTS
JAVA,JSP,SERVELTS  plz Send me Login Page by using core java ,Jsp,Servelts
java - JSP-Servlet
java  why is required to write both jsp and servlet in a application of java
Java or Jsp code - JSP-Servlet
Java or Jsp code  Hello Sir, How to create the code for the password recovery page(like forgot gmail password question and answer page)using the radion buttons in display the same page in jsp.I need only how to make
java+jsp - Java Beginners
java+jsp  I want to know how can I use java class in my jsp page?i'm...; Password:     --------------------------------- java file...://www.roseindia.net/jsp/ Thanks
A Java Program by using JSP
A Java Program by using JSP  how to draw lines by using JSP plz show me the solution by using program
java (servlet) - JSP-Servlet
java (servlet)  how can i disable back button in brower while using servlet or JSP
Java JSP - JDBC
Java JSP  JDBC connectivity in JSP?  Hi Friend, Please visit the following link: http://www.roseindia.net/jsp/Accessingdatabase-fromJSP.shtml Hope that it will be helpful for you. Thanks
java bar charts and jsp
java bar charts and jsp  Hi, Can any one help me out in how to create java bar charts using jsp with the help of data base table values? thanks.../jsp/draw-statistical-chart-jsp.shtml
Java Code - JSP-Servlet
Java Code  Write a JSP program which displays a webpage containg arrival of new items within a particular month in the different branches of a retail company
JSP - Java Beginners
JSP  sir, how to use in core jave code?This is not servlet.how to redirect from core java to servlet or jsp or html file
java - JSP-Servlet
java   can anyone help me with an idea to develop whiteboard using jsp. it is very important for me. Thank you. Ram
Java - JSP-Servlet
Java, JSP vs Servlet  If anyone have idea about how to use all these technologies in one project ..please share with me. Thanks
Java - JSP-Servlet
Java  Dear Deepak, In my Project we need to integrate Outlook Express mailing system with java/jsp. thanks & regards, vijayababu.m
java charts - JSP-Servlet
java charts  Hi,can any one tell me how to create dyanamic charts wrt database contents by using jsp-servlet
Display Java in JSP
Display Java in JSP  please i need urgent help. How can i display Java Applet created in netbeans in JSP?. the Application involves MYSQL Database connection. Thanks
jsp - Java Beginners
currently logged in, using jsp and java bean mysql as back end. urgent reply pls ... visit for more information. http://www.roseindia.net/jsp/ http://www.roseindia.net/jsp/loginbean.shtml http://www.roseindia.net/jsp/loginstatus.shtml
java script - JSP-Servlet
java script  hello buddy......i m new to here....please help me to solve my problem i have a jsp page with pre populated value comming from other jsp.....ones i submitted i have to clear that page and i have to submite
java - JSP-Interview Questions
java  hi.. snd some JSP interview Q&A and i wnt the JNI(Java Native Interface) concepts matrial thanks krishna  Hi friend, Read more information. http://www.roseindia.net/interviewquestions/jsp-interview
JSP using java - Java Beginners
JSP using java  sir, In my jsp page contains 3 hyperlinks say (link1 link2 link3).I want to write some java code using servlet for each hyperlinks.how to forward JSP page to servlet.I m using 3 hyperlinks in my page.My
java servet +jsp+mysqldatabase
java servet +jsp+mysqldatabase  I created three servlets(based on title, bookname, author) and one jsp page. in jsp page i put one dropdown list box(that is title, author, bookname) and created mysql database column values
Java - JSP-Servlet
Java  Hi All, How to integrate Outlook Express with java/jsp. Plase any one help me. thanks®ards, vijayababu.m  Hi Friend, Use the following: Send Mail Thanks
java and oracle - JSP-Servlet
java and oracle  I am developing a small project where I need to upload the resume of the employee and store it into database and retrieve the same... and jsp
java-script,jsp - JSP-Servlet
java-script,jsp   how can i shift to other page when my timer shows t<=0 .i.e timeout?   Hi Friend, Try the following code: timer.jsp: var time = null function go() { window.location = 'form.jsp
jsp code - Java Beginners
JSP code and Example  JSP Code Example
java,servlet,jsp - JSP-Servlet
java,servlet,jsp   i am doing a project on online examination system and in that there are problems that-- 1.i want to disable the back,forward and refresh button.Please give me the code for google crome browser. 2.suppose
JSP - Java Server Pages
JSP JSP stands for Java Server Pages. JSP is Java technologies for creating dynamic web applications. JSP allows the developer to embed Java code inside HTML. It makes the development of dynamic web application very easy in Java
Jsp count and java bean - JSP-Servlet
Jsp count and java bean  Please am on a project and i want to create a countdown timer that will have this format HH:MM:SS. Am working with jsp and java beans please somebody help.  Hi Friend, Try the following
Java Problem - JSP-Servlet
Java Problem  How to run a Simple JSP program ? what steps... the webapps folder of apache tomcat. 5)Create a jsp file 'hello.jsp'.You can put your jsp file either inside the web application folder along with WEB-INF or you
java servlets - JSP-Servlet
java servlets  how to get the parameter value of input type file using java servlets  Hi, You can use request.getParameter(). In Jsp, --- --- IN servlet, String fileName=request.getParameter('fl'); If you
jsp - Java Interview Questions
What is Java JSP and Java Servlet  What is JSP? and ..What is Servlet in Java?  jsp: separate the prsentation and business logic.(custom.... * Abbreviation for JSP is Java Server Pages. That is java code can
Converting jsp variable to java variable
Converting jsp variable to java variable  Hi how to convert java script variable to java variable on same jsp page
java/jsp code to download a video
java/jsp code to download a video  how can i download a video using jsp/servlet
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java... : Example of Extends Attribute of page Directive in JSP
how to call a java class in jsp - JSP-Servlet
how to call a java class in jsp  hi.. friends iam new to roseindia.i found it very nice site to clarify our douts. i have a problem to use my java... : Example of Extends Attribute of page Directive in JSP
JSP - Java Beginners
JSP  Hai friends, I want to use the flash image on jsp or java script, if i click the image then it goes to the next page...... If any one... the following link: http://www.roseindia.net/jsp/add-flash-jsp.shtml Hope
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have been given an assignment where I have to fix existing issues in the tool(created using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen
java - JSP-Interview Questions
Java database connectivity and accessing the database  Please explain, what is Java database connectivity and how to access the database?  Java Database Connectivity in short JDBC is an interface used to access database
java beans - JSP-Servlet
java beans  how to get the values from this page to java page bcoz i want to insert these values into table... the problem visit to : http://www.roseindia.net/jsp/usingbeansinjsp.shtml Thanks
Java Mail - JSP-Servlet
Java Mail  hi, i refer ur J2EE Tutorial - Send Email From JSP & Servlet to send emails from my application.but when i run the jsp it will throw thhese exceptions. ERROR.....javax.mail.SendFailedException: Sending failed
Advertisements
 

 

 

DMCA.com