Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Text in if condition is not displayed in the browser

Reply
Thread Tools

Text in if condition is not displayed in the browser

 
 
shanu
Guest
Posts: n/a
 
      07-27-2008
Hello everyone!
Im new wth JSP and facing a problem.
first of all here is the coding of my JSP file:-

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

<%
Connection con=null;
PreparedStatement ps=null;

String Eid=request.getParameter("T1");
String empname=request.getParameter("T2");
String design=request.getParameter("D1");
String dep=request.getParameter("T4");
String addr=request.getParameter("T5");
String mail=request.getParameter("T6");
String birth=request.getParameter("T7");
String join=request.getParameter("T8");

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbcdbc:es123", "","");

ps=con.prepareStatement("select * from addition where emp_id='"Eid"'
");
ResultSet rs=ps.executeQuery();

if(!rs.next())
{

PreparedStatement ps1=con.prepareStatement("insert into addition
(emp_id,ename,designation,dept,add,email,dob,doj)" +
"
values('"Eid"','"empname"','"design"','"dep"','"ad dr"','"mail"','"birth"','"join"')");

ResultSet rs1=ps1.executeQuery();
%>


<H1> SUCCESS DATA SAVED!</H1>



<% }
else { %>

<H1>CANNOT ADD!<br> EMPLOYEE ID ALREADY EXIST IN THE DATABASE!</H1>

<% }
}
catch(Exception e){}
finally{
try{
if(con!=null){
ps.close();
con.close();
}
}
catch(Exception r){}
}
%>

<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<title><jsp database connection></title>
</head>
<body>

<a href="select1.jsp">click to move back</a>

</body>
</html>



--------------------------------------------------------------------------------

The problem I am facing is that when an entry successfully gets saved
in the database( when i refresh access a new row is added
successfully) but the browser doesnot displays this- " SUCCESS DATA
SAVED! "

and for the else case it works fine and displays CANNOT ADD! EMPLOYEE
ID ALREADY EXIST IN THE DATABASE!.

Im confused else condition is working properly but if condition is
not. I want "SUCCESS DATA SAVED " to be displayed in the browser
window.

My Web Browser- IE-7
Server- Tomcat6.0
DB- MS ACCESS 2007
JDK- JDK1.6
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      07-27-2008
On Jul 27, 12:37*pm, shanu <(E-Mail Removed)> wrote:
> Hello everyone!
> Im new wth JSP and facing a problem.


If that problem is with spelling, note that FF will
highlight words it does not understand, in red. This
helps when posting via GG, since things like 'Im' and
'wth' are underlined.

Note also that a good group for people new to Java,
is comp.lang.java.help

> <H1> SUCCESS DATA SAVED!</H1>


Stop SHOUTING at your users. They are not DEAF!

> catch(Exception e){}


..and stop swallowing exceptions in broken code.
<http://pscode.org/javafaq.html#stacktrace>

--
Andrew Thompson
http://pscode.org/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with while condition OR condition Bill W. Ruby 13 05-09-2011 09:42 PM
how can i store punjabi text in database. this text must be displayed in punjabi in the browser. sandhu ASP .Net Datagrid Control 1 05-17-2007 11:50 AM
Re: Images are not displayed by a browser. George Ter-Saakov ASP .Net 0 01-11-2007 07:59 PM
Japanese Text not displayed on Image Generated by Servlet on winXP, Linux but displayed on Win2000 boney Java 1 12-15-2006 02:24 PM
Condition outside loop or separate loop for different condition? - Java 12 06-15-2005 08:50 AM



Advertisments