Home Answers Viewqa JSP-Servlet JSP,JDBC and HTML(Very Urgent)

 
 


Ragavendran.R
JSP,JDBC and HTML(Very Urgent)
1 Answer(s)      4 years and 11 months ago
Posted in : JSP-Servlet

View Answers

July 9, 2008 at 4:08 PM


Hi raghavendran, I completed the code:

I am not using any html. I used only jsp & jdbc.

HOme Page:
FindEmp.jsp

<%@ page language="java" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.sql.*" %>

<HTML>

<BODY BGCOLOR="LIGHTYELLOW">
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:Employee","","");
Statement stmt=null;
%>
<FORM METHOD="GET" ACTION="process.jsp">

<H3> <P ALIGN="CENTER"> <FONT SIZE=6> EMPLOYEE DETAILS </FONT> </P> </H3> </BR> </BR>
<BR>
<BR>
<TABLE CELLSPACING=5 CELLPADDING=5 BGCOLOR="LIGHTBLUE" COLSPAN=2 ROWSPAN=2 ALIGN="CENTER">
<TR>
<TD> <FONT SIZE=5> Enter Employee ID </TD>
<TD> <INPUT TYPE="TEXT" ID="id" NAME="id"> </FONT> </TD>
</TR>
<TR>
<TD> <FONT SIZE=5> Enter Employee Name </TD>
<TD><INPUT TYPE="TEXT" ID="name" NAME="name"> </FONT> </TD>
</TR>
<TR>
<TD> <FONT SIZE=5> Enter New Name (For UPDATE only) </TD>
<TD><INPUT TYPE="TEXT" NAME="nname"> </FONT> </TD>
</TR>
<TR>
<TD>Employee Ids: <SELECT NAME="empIds" ONCHANGE="document.getElementById('id').value=this.options[this.selectedIndex].text"><option>Select One</option>
<%
String rec="SELECT Emp_code,Emp_name FROM Employee";
try {
stmt=con.createStatement();
ResultSet rs=stmt.executeQuery(rec);
while(rs.next())
{
%>
<option><%= rs.getInt(1)%></option>
<%}
}
catch(Exception e){System.out.println(e);}
%>
</SELECT>
</TD>
</TR>
<TR> <FONT SIZE=6> <B>
<TD><INPUT TYPE="RADIO" NAME="r1" VALUE="add" >Insert </TD>
</TR>
<TR>
<TD><INPUT TYPE="RADIO" NAME="r1" VALUE="del" >Delete </TD>
</TR>
<TR>
<TD><INPUT TYPE="RADIO" NAME="r1" VALUE="mod" >Update </TD>
</TR>
<TR>
<TD><INPUT TYPE="RADIO" NAME="r1" VALUE="query">Query </TD>

</TR>
</FONT> </B>
<TR> <TD><INPUT TYPE="SUBMIT" VALUE="Submit"> <INPUT TYPE="RESET" VALUE="Reset"> </TD>
</TR>
<%
if(session.getAttribute("empcode")!=null && session.getAttribute("empname")!=null)
{
%>
<script language="javascript">
document.getElementById('id').value=<%=session.getAttribute("empcode").toString()%>
document.getElementById('name').value='<%=session.getAttribute("empname").toString()%>'
</script>
<%
session.removeAttribute("empcode");
session.removeAttribute("empname");
}%>
</FORM>

</BODY>
</HTML>


Note: Please align textboxes & combo box according to ur requirement.

process.jsp:

<%@ page language="java" %>
<%@ page import="java.lang.*" %>
<%@ page import="java.sql.*" %>


<html>
<body>
<%
Connection con=null;
Statement stmt=null;
//ResultSet rs=null;
String radioSelected=request.getParameter("r1");
String name=request.getParameter("name");
String code=request.getParameter("id");

String query=null;
int EmpID=Integer.parseInt(code);
int status;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:Employee","","");
stmt=con.createStatement();
if(radioSelected.equals("add")){
query="INSERT INTO Employee (Emp_code,Emp_name) VALUES("+EmpID+",'"+name+"')";
status=stmt.executeUpdate(query);
if(status==1){//This is for successful insertion
%>
<script language="javascript">
alert("Insertion successful");
document.location="FindEmp.jsp";
</script>
<%
}else{
%>
<script language="javascript">
alert("Insertion Failed");
document.location="FindEmp.jsp";
</script>
<% }
}
else if(radioSelected.equals("del")){
query="DELETE * FROM Employee where Emp_code="+EmpID+"";
status=stmt.executeUpdate(query);
if(status==1){//This is for successful Deletion
%>
<script language="javascript">
alert("Deletion successful");
document.location="FindEmp.jsp";
</script>
<%
}else{
%>
<script language="javascript">
alert("Deletion Failed Bcoz,Employee Id Not Found");
document.location="FindEmp.jsp";
</script>
<% }

}
else if(radioSelected.equals("mod")){
String new_name=request.getParameter("nname");
query="UPDATE Employee SET Emp_name='"+new_name+"' where Emp_code="+EmpID+"";
status=stmt.executeUpdate(query);
if(status==1){//This is for successful updation
%>
<script language="javascript">
alert("Record Updated successfully");
document.location="FindEmp.jsp";
</script>
<%
}else{
%>
<script language="javascript">
alert("Updation Failed");
document.location="FindEmp.jsp";
</script>
<% }
}
else if(radioSelected.equals("query")){
query="Select Emp_code, Emp_name from Employee where Emp_code="+EmpID+"";
ResultSet rs=stmt.executeQuery(query);

if(rs.next()) //If record found....
{
session.setAttribute("empcode",rs.getInt(1));
session.setAttribute("empname",rs.getString(2));
%>
<script language="javascript">
document.location="FindEmp.jsp";
</script>
<%
}
else{
%>
<script language="javascript">
alert("Employee Id Not Found");
document.location="FindEmp.jsp";
</script>
<%}
}
}
catch(Exception e){
e.printStackTrace();
}
finally{
con.close();
stmt.close();
//rs.close();
}

%>
</body>
</html>


For query radio button, i changed slightly. Not immediately after clicking the radio button, after selecting the radio button then click submit button. Then it displays selected employee id details.

I didn't do any validations for ur text boxes like number only allowed for employee id text box etc.

Thanks
Sreenivas









Related Pages:
JSP,JDBC and HTML(Very Urgent) - JSP-Servlet
JSP,JDBC and HTML(Very Urgent)  Respected Sir/Madam, Thanks... details from database using JDBC and JSP. The home page i.e HTML Page must contain... the code: I am not using any html. I used only jsp & jdbc. HOme Page
jsp-jdbc - JDBC
jsp-jdbc  Hi! html- jsp-jdbc program from the html form where... jsp frequently. I am getting error through request.getParameter(). can you please... should I pass request.getParameter or fname, lname, add,phones (from html input
Very Very Urgent -Image - JSP-Servlet
Very Very Urgent -Image  Respected Sir/Madam, I am R.Ragavendran.. I am working with JSP and JDBC.. In the home JSP page, there is a button... ID) inside the text box of my home JSP page.. How to check whether
jsp - JDBC
jsp  -------------------------------------------------------------------------------- how to receive data into jsp from html for dropdown boxes
jsp - JDBC
JSP Storing Data, Datatype vale in SQL   Storing Data, Datatype vale...;<%Connection con = null; String url = "jdbc:mysql://localhost:3306..., will help you in storing date in sql database.See how to insert data from html
&nbsp;(very urgent) - Design concepts & design patterns
 (very urgent)  hi friends, This is my code in html                   
very urgent - Design concepts & design patterns
very urgent  Hi friends, I have a page layout with a menu on the left, the menu looks perfect in my personal system but the spacing and the rollover... control over the CSS not the HTML itself Thanks in advance.Give me solution
Servlet and Jsp - JDBC
Servlet and Jsp  Hai I need a program to update the table records ......The program should have only update code.....It shouldnot combine with Add or delete code. It is very urgent ... Send me the full code
Servlets and Jsp - JDBC
and Jsp.It is very urgent ,please send the program
JSP and JDBC - JSP-Servlet
JSP and JDBC  Respected sir/Madam, I am R.Ragavendran.. I am in urgent need of programming from roseindia team.. My requirement... for JDBC codings must be present.. NOTE: When User clicks Insert,for example
servlets And Jsp - JDBC
me.It is very urgent .I tried but i couldn get it properly.  Hi Friend, Your problem is not very clear to us so could you please clarify it to us
Help on JSP and JDBC - JDBC
Help on JSP and JDBC  Retrieve data from Database in JSP and JDBC... for connection from that class get values. jsp only for view , even html designers can...;% Connection con = null; String url = "jdbc:mysql://localhost:3306/"
Help on JSP - JDBC
and Enquiry system. I had completed the front end design with the help of html,delete and search the database from the html file with the help of JSP.  hi...;jdbc:oracle:thin@localhost:1521:xe","scot","tiger"
Displaying Date in jsp - JDBC
in a database.i am getting input value from HTML and i use jsp application to interact with database.My JSP code for inserting Date is below: String dateStr... ----------------------------------------- Read for more information. http://www.roseindia.net/jsp/ Thanks
Servlet and Jsp - JDBC
code of this. It is very urgent.Thanks in advance
very urgent
very urgent  ** how to integrate struts1.3 ,ejb3,mysql5.0 in jboss server with myeclipse IDE
courier management service (using servlets,jsp,jdbc)
courier management service (using servlets,jsp,jdbc)   is anyone having information about courier management service ? plz share it .its urgent THANKING YOU IN ADVANCE
Urgent
J2ME programming  Hi, J2ME programming - How to learn J2ME Programming very fast? Thank You
HTML
HTML       Introduction to HTML Here, we will introduce you to the basics of HTML. HTML stands for Hyper Text
Pop up Very Very Urgent - JSP-Servlet
='' Its Very Urgent.. Please send me the coding asap.. Thanks...Pop up Very Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. I got your reply.. Thank you very much for the response. Now I am sending
HTML
HTML - Hypertext markup language tutorials Learn HTML with the help of many examples. We have created many easy to understand HTML examples. These examples will help you in understanding HTML very quickly HTML is used to create web
Help Very Very Urgent - JSP-Servlet
requirements.. Please please Its Very very very very very urgent... Thanks...Help Very Very Urgent  Respected Sir/Madam, I am sorry..Actually.../jsp/ Thanks.   function trim(stringToTrim
Program Very Urgent.. - JSP-Servlet
Program Very Urgent..  Respected Sir/Madam, I am R.Ragavendran.... reference. http://www.roseindia.net/jsp/popup-window-using-ajax-in-jsp.shtml... its most urgent.. Thanks/Regards, R.Ragavendran..   Hi friend
JSP and AJAX- very urgent - Ajax
JSP and AJAX- very urgent  Respected Sir/Madam, I am Ragavendran.. I have a simple doubt.. At present, I am in a module of the project... Plz its very very Urgent.. Regards, Ragavendran
JSP and AJAX very urgent - Ajax
JSP and AJAX very urgent  Hi Team, This is Ragavendran.R.. I have a very basic doubt in AJAX. While Using AJAX, of course, there will be tag involved in JSP page. But in my current project, I am using too many tags
jsp - JDBC
variable. JSP Page... Login Successful <%-- <jsp:forward page="studenthome.jsp"/>...   2)action.jsp: JSP
jsp - JDBC
jsp  how to link jsp code with next htmlcode.  Hi keerthi, Can u explain ur question clearly? What is your exact Requirement
jsp - JDBC
: Unable to compile class for JSP An error occurred at line: 20 in the jsp file...\localhost\Airlines-Project\org\apache\jsp\Flightdetails_jsp.java:69: cannot find symbol symbol : variable src location: class org.apache.jsp.Flightdetails_jsp
jsp - JDBC
about update at http://www.roseindia.net/jsp/implement-javascript
JSP - JDBC
JSP Store Results in Integer Format  JSP Example Code that stores the result in integer format in JSP  Hi! Just run the given JSP Example...;/b></td><% Connection con = null; String url = "jdbc:mysql
jsp - JDBC
jsp  I have one jsp code.but it is included oracle databse...("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle... = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:oracle","scott","tiger"); I
jsp - JDBC
jsp  i am doing project in java using jsp as font end and microsoft access as back end my project airline ticketing reservations how can i give hyperlink to database rows in jsp code.   First
its very urgent please help me
its very urgent please help me  how can i retrieve all images from ms access database and display in jsp pages
Ple help me its very urgent
Ple help me its very urgent  Hi.. I have one string 1)'2,3,4' i want do like this '2','3','4' ple help me very urgent
Query regarding JSP, JDBC
Query regarding JSP, JDBC  can I get the code for the question asked by me regarding JSP,JDBC
very urgent, want to submit my project on monday
very urgent, want to submit my project on monday  i have the code for connected combo-boxes(jsp). But the thing i want to know is, how to access the values selected in those combo-boxes, for storing in database. in the case
very urgent - Java Server Faces Questions
check it once and give me a correct solution. It is very urgent for me. Thanks...very urgent  Hi sir, yesterday i send total my code to find where i have done mistake ,you send a reply for that also but in that you told remove
very urgent - Java Server Faces Questions
very urgent  Hi sir, see my code and please tell me mistake. it is very urgent for me. here is my code: addmin.jsp: Users... deepak@roseindia.net 8888 deepak kumar It is very urgent for me please give
Basic problem but very urgent - JSP-Servlet
Basic problem but very urgent  Respected Sir/Madam, I am... kind reference. http://www.roseindia.net/jsp/popup-window-using-ajax... me the cause of the problem asap because its most urgent.. Thanks/Regards
Programming help Very Urgent - JSP-Servlet
Please please its very urgent.. Thanks/Regards, R.Ragavendran..  Hi friend, Read for more information, http://www.roseindia.net/jsp...Programming help Very Urgent  Respected Sir/Madam, Actually my code
Popup very urgent plz - JSP-Servlet
Popup very urgent plz  Respected Sir/Madam, I am R.Ragavendran.. I got your reply.. Thank you very much for the response. Now I am sending the code...='' Its Very Urgent.. Please send me the coding asap.. Thanks/Regards
&nbsp;(very urgent) - Java Server Faces Questions
 (very urgent)  hi friends, This is my code in JSF                    
Radio Buttons in DB Very Urgent - JSP-Servlet
Very Urgent.. Please send...Radio Buttons in DB Very Urgent  Respected Sir/Madam, I am R.Ragavendran.. I got your reply.. Thank you very much for the response. Now I am sending
Validating Number Very Urgent - JSP-Servlet
Validating Number Very Urgent  Respected Sir/Madam, I am...('id').value= document.getElementById('name').value='' Its Very Urgent.. Please send me the coding asap.. Thanks/Regards, R.Ragavendran.. 
Please help me... its very urgent
Please help me... its very urgent  Please send me a java code to check whether INNODB is installed in mysql... If it is there, then we need to calculate the number of disks used by mysql
jsp jdbc Spring
jsp jdbc Spring  I need to create the form in jsp with one field.The field is user id. On submitting the form all the details associated... how to link the user id field of jsp with the database using spring mvc
Jsp,JDBC - JDBC
Jsp,JDBC  Write a Program using Servlet,JSP, JDBC and XML to create a web application for a courier company to provide an online help in tracking the delivery status of items.  Hi friend, For solving the problem
Simple Program Very Urgent.. - JSP-Servlet
Simple Program Very Urgent..  Respected Sir/Madam, I am... database using JDBC Database. Please send me the modified coding asap because its most urgent.. Thanks/Regards, R.Ragavendran..  

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.