i want to display where i entered values to same page

Ads

 
 

Share on Google+Share on Google+

Arunkumar
i want to display where i entered values to same page
4 Answer(s)      4 years and 4 months ago
Posted in : Development process

hi friends !!

i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format.

Ads
View Answers

May 23, 2013 at 3:11 PM


hi friend,

Try the following code, may this will be helpful for you

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<!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>Student Record</title>
</head>
<body>
<h2>Student Record</h2>
<form action="#" method="post">
<div>
<div align="left">
<table>
<tr>
<td>
Select Course <select name="course">
<option value="select">select</option>
<option value="MCA">MCA</option>
<option value="BCA">BCA</option>
</select>
</td>
<td></td>
<td align="right">Enter Roll No</td>
<td><input type="text" name="roll"/></td>
</tr>
</table>
</div>
<div>
<table>
<tr>
<th>Subject</th>
<th>Obtained Marks</th>
<th>Full Marks</th>
</tr>
<tr>
<td align="center">C</td>
<td align="center"><input type="text" size="5" name="c"/></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">Java</td>
<td align="center"><input type="text" size="5" name="java"/></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">.Net</td>
<td align="center"><input type="text" size="5" name="net"/></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">VB</td>
<td align="center"><input type="text" size="5" name="vb"/></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">DBMS</td>
<td align="center"><input type="text" size="5" name="dbms"/></td>
<td align="center">100</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr><td></td><td align="center"><input type="submit" value="submit"/></td></tr>
</table>
</div>
</div>
</form>

Continue....



May 23, 2013 at 3:13 PM


<%!
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
String driverName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://localhost:3306/record";
String user = "root";
String psw = "root";
%>

<%
String c = request.getParameter("c");
String j = request.getParameter("java");
String n = request.getParameter("net");
String v = request.getParameter("vb");
String d = request.getParameter("dbms");
String course = request.getParameter("course");
String roll = request.getParameter("roll");
if(!(course == null || course.isEmpty()))
{
    if(!(roll == null || roll.isEmpty()))
    {
        if(!(c == null || c.isEmpty()))
        {
            if(!(j == null || j.isEmpty()))
                if(!(n == null || n.isEmpty()))
                    if(!(v == null || v.isEmpty()))
                        if(!(d == null || d.isEmpty()))
                        {
                            int cmarks = Integer.parseInt(c);
                            int jmarks = Integer.parseInt(j);
                            int nmarks = Integer.parseInt(n);
                            int vmarks = Integer.parseInt(v);
                            int dmarks = Integer.parseInt(d);
                            int rollNo = Integer.parseInt(roll);
                            int total = cmarks+jmarks+nmarks+vmarks+dmarks;
                            int avg = (total)/5;
                            int percent = avg;
                            String grade ="";
                            if(percent < 40){
                                grade = "E";
                                }
                            else if(percent >= 40 && percent <=44){
                                grade = "D";
                                }
                            else if(percent >=45 && percent <=49){
                                grade = "D+";
                                }
                            else if(percent >=50 && percent <=54){
                                grade = "C-";
                                }
                            else if(percent >=55 && percent<=59){
                                grade = "C";
                                }
                            else if(percent >=60 && percent <=64){
                                grade = "C+";
                                }
                            else if(percent >=65 && percent<=69){
                                grade = "B-";
                                }
                            else if(percent >=70 && percent <=74){
                                grade = "B";
                                }
                            else if(percent >=75 && percent <=79){
                                grade = "B+";
                                }
                            else if(percent >=80 && percent <=84){
                                grade = "A";
                                }
                            else if (percent >=85 && percent <=100){
                                grade = "A+";
                                }
                        %>

Continue...



May 23, 2013 at 3:15 PM


<div>
<div>
<table>
<tr>
<td align="left"><b>Course</b></td><td></td>
<td align="center"><%=request.getParameter("course") %></td>
<td align="right"><b>Roll No : </b></td>
<td align="center"><%=request.getParameter("roll") %></td>
</tr>
</table>
</div>
<div>
<table border="1">
<tr>
<th>Subject</th>
<th>Obtained Marks</th>
<th>Full Marks</th>
</tr>
<tr>
<td align="center">C</td>
<td align="center"><%=cmarks %></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">Java</td>
<td align="center"><%=jmarks %></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">.Net</td>
<td align="center"><%=nmarks %></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">VB</td>
<td align="center"><%=vmarks %></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center">DBMS</td>
<td align="center"><%=dmarks %></td>
<td align="center">100</td>
</tr>
<tr>
<td align="center"><b>Aggregate Marks</b></td>
<td align="center"><%=total %></td>
</tr>
<tr>
<td align="center"><b>Grade</b></td>
<td align="center"><%=grade %></td>
</tr>
</table>
</div>
</div>

Continue...


May 23, 2013 at 3:15 PM


<%
try{
Class.forName(driverName);
con = DriverManager.getConnection(url,user,psw);
String sql = "insert into sturecord values(?,?,?,?,?,?,?,?)";
ps = con.prepareStatement(sql);                             
ps.setInt(1, rollNo);
ps.setString(2, course);
ps.setInt(3, cmarks);
ps.setInt(4, jmarks);
ps.setInt(5, nmarks);
ps.setInt(6, vmarks);
ps.setInt(7, dmarks);
ps.setString(8, grade);
ps.executeUpdate();                             
out.println("Added Successfully");
}
catch(Exception e)
{
out.println(e);
}
finally
{
ps.close();
con.close();
}
}
}
}
}
%>

    </body>
    </html>

Ads









Related Tutorials/Questions & Answers:
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
Advertisements
i want to display where i entered values to same page
i want to display where i entered values to same page  hi friends !! i have a values from jsp page .and i want to store that values into DB at the same time i want to show immediatlly on same jsp page with tabular format
i want to update values
i want to update values  in my form i have 2 submit buttons one for edit and another for update on page load all my details need to fetch from database and it need to insert automatically in to disabled text boxs and once i press
I want to display 10,000 records in a jsp page.Can I display page by page?
I want to display 10,000 records in a jsp page.Can I display page by page?  When I submit a form it says "ERROR: Query request too large. Total rows... print page by page or have say 900 records per page in a jsp? Should I have
same thing i want but from db..
same thing i want but from db..  http://www.roseindia.net/tutorial/javascript/dynamicCombo.html same thing i want but from db
i want display integer number in a string of statement
i want display integer number in a string of statement  i want display integer number in a string of statement
i want to retriev and update in same form but its not working pls help....
i want to retriev and update in same form but its not working pls help.... ...;div id="page"> <div id="header"> <a href="#"><h1...("refno"); re=stmt.executeQuery("select * from passapp where refno='"+refno
I want display frame in another frame - Java Beginners
I want display frame in another frame  Hi all, this is available in jsps folder and Admin.jsp is main page i m taking two frame fisrt is header.jsp and another is footer.jsp I want to display footer.jsp is display
Want to display Arraylist items on same row in JSF
Want to display Arraylist items on same row in JSF  I want do display values of one arraylist on same row using datatable? If i use h:column, then it goes on different row. Please tell me, how I can do it?   Hi Friend
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p
How to disable Browser's back button (at the same time i want my own back button to be enabled) :p  Hi, I have designed a "back" button for jsp page. Now I want to disable Browser's default button So that people will use "back
How can I output text typed in textarea by user on the same page?
How can I output text typed in textarea by user on the same page?  I have a basic HTML page where I have created a textarea for users comments. I would like to take the comments and append them to the same page for all to see
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
display results on same jsp page
display results on same jsp page  is there any method to display search results from database on the same jsp page where i give the inputs using struts 1.2
i want to learn Jquery
i want to learn Jquery  i want to learn jquery can u plz guide me   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... for particular jsp pages? If we want to develop any jsp pages using eclipse where we can
I want this jsp answers
I want this jsp answers    How can we declare third party classes and interfaces inside our jsp page? How can we declare and definr global variables... for particular jsp pages? If we want to develop any jsp pages using eclipse where we can
how to store multiple values from drop down in database where i am using java struts 1.3
how to store multiple values from drop down in database where i am using java struts 1.3  hii, i am coding a form where i need a keyskills attribute where i have to select multiple keyskills. but it is taking only one valuee.. i
i want for statement codding
i want for statement codding  what is the for condition following out put 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report .. help out asap
I want to update the multiple values of database depending on checkbox..? Please help me out..
I want to update the multiple values of database depending on checkbox..? Please help me out..   Hi .. I want to Update the multiple values of database using checkboxes and want to set the session for selected checkboxes
i want code for these programs
i want code for these programs   Advances in operating system Laboratory Work: (The following programs can be executed on any available and suitable platform) Design, develop and execute a program using any
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
i want to create invoice report editable. values should be taken from dabase and editable .. help out asap   i want to create invoice report editable. values should be taken from dabase and editable .. help out asap
display all the values on next page
when i return on first page it should display my selected values in textbox...display all the values on next page  i am inserting values... values are inserting in the database and i am moving on another page after
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.
I want to display the quantity of the selected item of a drop down list in a textbox. The data is stored in database.  The code for retrieving data..."); pre = con.prepareStatement("select Quantity from library.booklist where Book
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.
I am creating one jsp page in which I read in a text file, then display that data in tabular format. Now I need to calculate a total.  I am reading...... } The output displays 4 rows and 2 columns. How can I calculate the total
how can i display a editable result of form?
is display on text. i cant modify them. i have a form with hundreds of checkbox. i want to display form result in same page i have alredy created a hidden div which... display on same result div which is a part of form and in that div i have 2 buttons
I want solution for this jsp program..
I want solution for this jsp program..   <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <%@ page import="java.sql.*" %> JSP Page <%! String
I need Oracle connector jar file. where will i download?
I need Oracle connector jar file. where will i download?  I need Oracle connector jar file. where will i download