Win a copy of Java by Comparison (eBook) this week in the Java in General forum!

Kumaran Sowrirajan

Ranch Hand
+ Follow
since Oct 15, 2001
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kumaran Sowrirajan

Hi friends
Please give me a solution for my doubt.
I am Creating a dynamic SQL query such that if the user selects any value from the picklist then that I set the value in PreparedStatement using the following statement.
For simplification, I write the simple query but the actual query is big.
I am using Prepared Statement to set the value.
DBSQL Query = "select * from table1 where id=?"

StringBuffer sb = new StringBuffer();
sb.append("select * from table1 where id=?");
ps = con.prepareStatement(sb.toString());
ps.setInt(1,value);
rs = ps.executeQuery();
Suppose if the User did not select any value then I need to return all the values from the table.
DBSQL Query = select * from table1 where id is not null
I do not know how to formulate the prepared statement such that it will match the exact DBSQL Query.
Give me a proper solution how to handle this kind of situation?
Thanks,
Kumaran.S
Hi Suresh
Regarding the blank page in PDF reports , We found that if the data is copied ad pasted to "note window" in application, the data is
converted with some special character as "". Even though this character is allowed to save in database, the XML/XSL has the limitation to display this character which is not even in the list of key board buttons.
Can you please tell me why this is happened and what is the solution for this?
Thanks,
Kumaran.S
14 years ago
Hi Suresh
Can you explain me detail regarding how to manage the space between the paragraphs?
we are using XSL-FOP.
Thanks,
Kumaran.S
14 years ago
Hi
we are generating PDF report from the Servlet if the client enters data through their forms.But if client enters any data except & and < characters the report is generating fine.but if the client enters & or < characters then the report is not generated.also if the client enters space between then paragrapgh if client entered the data as paragraph then in report the space will be collapsed and the report is showing as single paragrapgh text.
Can you please tell me what is the problem here or how can i solve the problem?
Thanks,
Kumaran.S
14 years ago
Hi
I need to show the Image as well as some data related to that Image in JSP.Image and their related data's are stored in database.
Because both the content type are different also i dont know how to show the different content type in single request?
Can you please tell me how can i show both the data [Image and Text] together.
Thanks,
Sujatha Kumaran.
15 years ago
JSP
Hi friends
I am new to JCE.I am doing the simple program to encrypt and decrypt the string, but while i compiling i am getting these errors.
Program :-
import javax.crypto.cipher;
import javax.crypto.KeyGenerator;
import java.security.Key;
import java.security.Security;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyEception;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.BadPaddingException;
public class encryptTest
{
public static void main(String args[])
{
String password = "HelloWorld";
Security.addProvider(new com.sun.crypto.provider.SunJCE());
try
{
KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");
byte[] plain_password = password.getBytes();
String str_plain_password = new String(plain_password);
System.out.println("Plain Password = " + str_plain_password);
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] encrypted_password = cipher.doFinal(plain_password);
String str_encrypted_password = new String(encrypted_password);
System.out.println("Encrypted Password = " + str_encrypted_password);
cipher.init(Cipher.DECRYPT_CODE,key);
byte[] decrypted_password = cipher.doFinal(encrypted_password);
String str_decrypted_password = new String(decrypted_password);
System.out.println("Decrypted Password = " + str_decrypted_password);
}
catch(NoSuchAlgorithmException nsae)
{
System.out.println("No Such Algorithm Exception " + nsae.getMessage());
}
catch(NoSuchPaddingException nspe)
{
System.out.println("No Such Padding Exception " + nspe.getMessage());
}
catch(InvalidKeyException ike)
{
System.out.println("Invalid Key Exception " + ike.getMessage());
}
catch(IllegalStateException ise)
{
System.out.println("Illegal State Exception " + ise.getMessage());
}
catch(IllegalBlockSizeException ibse)
{
System.out.println("Illegal Block Size Exception " + ibse.getMessage());
}
catch(BadPaddingException bpe)
{
System.out.println("Bad Padding Exception " + bpe.getMessage());
}
}
}

Error :- import javax.crypto.cipher; ^ encryptTest.java:2: Class javax.crypto.KeyGenerator not found in import.
import javax.crypto.KeyGenerator; ^ encryptTest.java:6: Class java.security.InvalidKeyEception not found in import.
import java.security.InvalidKeyEception; ^ encryptTest.java:7: Class javax.crypto.NoSuchPaddingException not found in import.
import javax.crypto.NoSuchPaddingException; ^ encryptTest.java:8: Class javax.crypto.IllegalBlockSizeException not found in import.
import javax.crypto.IllegalBlockSizeException; ^ encryptTest.java:9: Class javax.crypto.BadPaddingException not found in import.
import javax.crypto.BadPaddingException;
I think this is mainly because of ClassPath problem.Can you please tell me what i need to do to rectify this error?.
Thanks
Kumaar.S
15 years ago
JSP
Hi Mark
I know that JDK1.4 is come with default provider which is provided by Sun.am i correct?
In %JAVA_HOME%/jre/lib/security/java.security automatically this providers are included.
security.provider.1=sun.security.provider.Sun
security.provider.2=com.sun.net.ssl.internal.ssl.Provider
security.provider.3=com.sun.rsajca.Provider
security.provider.4=com.sun.crypto.provider.SunJCE
security.provider.5=sun.security.jgss.SunProvider
Can you please tell me how to specify the provider in this program?
To rectify the class path error what are all the jar file i need to include and where to include and what are all the other things i need to do apart from adding provider.
I would like to know how can i find out whether my J2EE App Server having this providers?
Thanks,
Kumaar.S
15 years ago
Hi Mark
Nice to hear the Immediate Reply.Thanks...
But
I am doing the simple program to encrypt and decrypt the string.but while i compiling i am getting these errors.
Program :-
import javax.crypto.cipher;
import javax.crypto.KeyGenerator;
import java.security.Key;
import java.security.Security;
import java.security.NoSuchAlgorithmException;
import java.security.InvalidKeyEception;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.BadPaddingException;
public class encryptTest
{
public static void main(String args[])
{
String password = "HelloWorld";
try
{
KeyGenerator kg = KeyGenerator.getInstance("DES");
Key key = kg.generateKey();
Cipher cipher = Cipher.getInstance("DES");
byte[] plain_password = password.getBytes();
String str_plain_password = new String(plain_password);
System.out.println("Plain Password = " + str_plain_password);
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[] encrypted_password = cipher.doFinal(plain_password);
String str_encrypted_password = new String(encrypted_password);
System.out.println("Encrypted Password = " + str_encrypted_password);
cipher.init(Cipher.DECRYPT_CODE,key);
byte[] decrypted_password = cipher.doFinal(encrypted_password);
String str_decrypted_password = new String(decrypted_password);
System.out.println("Decrypted Password = " + str_decrypted_password);
}
catch(NoSuchAlgorithmException nsae)
{
System.out.println("No Such Algorithm Exception " + nsae.getMessage());
}
catch(NoSuchPaddingException nspe)
{
System.out.println("No Such Padding Exception " + nspe.getMessage());
}
catch(InvalidKeyException ike)
{
System.out.println("Invalid Key Exception " + ike.getMessage());
}
catch(IllegalStateException ise)
{
System.out.println("Illegal State Exception " + ise.getMessage());
}
catch(IllegalBlockSizeException ibse)
{
System.out.println("Illegal Block Size Exception " + ibse.getMessage());
}
catch(BadPaddingException bpe)
{
System.out.println("Bad Padding Exception " + bpe.getMessage());
}
}
}

Error :- import javax.crypto.cipher; ^ encryptTest.java:2: Class javax.crypto.KeyGenerator not found in import.
import javax.crypto.KeyGenerator; ^ encryptTest.java:6: Class java.security.InvalidKeyEception not found in import.
import java.security.InvalidKeyEception; ^ encryptTest.java:7: Class javax.crypto.NoSuchPaddingException not found in import.
import javax.crypto.NoSuchPaddingException; ^ encryptTest.java:8: Class javax.crypto.IllegalBlockSizeException not found in import.
import javax.crypto.IllegalBlockSizeException; ^ encryptTest.java:9: Class javax.crypto.BadPaddingException not found in import.
import javax.crypto.BadPaddingException;
I think this is mainly because of ClassPath problem.Can you please tell me what i need to do to rectify this error?
Thanks
Kumaar.S
[ January 27, 2003: Message edited by: Kumaran Sowrirajan ]
15 years ago
Hi
In My J2EE Web Application i stored my Database UserId and Password in the properties file.Since the properties file can be editable and the UserId and Password is stored as plain text everybody in our team and others are able to read those Userid and Password from the properties file.
What i want is how to encrypt the UserId and Password and i need to store that encrypted Userid and Password in the properties file.while retrieving the data from the properties file i need to decrypt the values.
I know that i have to use some crytography techniques.Can any one of you tell me how to do this?
Thanks,
Kumaar.S
15 years ago
Hi
I am new to this topic...
Anybody can tell me what is the difference between the XML messsaging and sending the message through SOAP?.Also i need to know Can i use the Tomcat server to implement the web services using SOAP?
Thanks
Kumaran.S
15 years ago
Hi Friends
Can anybody me the solution for my doubt i am facing in my application?
Doubt is....
In a jsp file under certain condition if that condition met i am redirecting to one jsp otherwise i am redirecting to another jsp?
I am using response.sendRedirect(String url); method to redirect from one page to another page.I used both the relative url as well as the absolute url as a parameter to that method.
This is working fine in IE 5.0 and above.Also in Netscape 6.0 and above.
But only in Netscape 4.76 browser,the session values are lost [turned to null value] if i am using sendRedirect method.I know that session values are persist between pages until the user session is expired.But in this case only in Netscape 4.76 my session gets expired with sendRedirect method.
Also i noted that if i am specifying the port number in the browser url to invoke the page then the session value will be lost.If i invoke the jsp page without giving port number then the session value is there it will take to me to exact destination page.
Also if i am using <jsp:forward> tag to forward to the destination page when that condition met then the session value is there.This will working in all the browsers.
Friends Can you tell me what i am doing wrong???
Thanks & Regards
Kumaran.S
15 years ago
JSP
Hi friends
Regarding the problem mentioned above...i didnt delete the cookies also even if i use the response.encodeRedirectURL() methos till the session variable shows the null value.
Finally i found one thing...if i specified the port number in the url to access the page then the session varaible value shows null.if i didnt mentioned the port number then the session value shows the exact value and redirected to the exact destination page.
like this....
http://localhost:80/test/test.jsp
it will not work in netscape 4.76
http://localhost/test/test.jsp
the above url is working fine
Can you tell me what i am doing wrong in that code?
Cheers
Kumaran S
15 years ago
JSP
Hi
The code submitted below is working in Netscape 6.0 also but not in Netscape 4.76???
Herewith i am sending the example code....if i am using response.sendRedirect() in the place of <jsp:forward>? then the session variable gives a null value in the next page if i use response.sendRedirect() method.
<%@ page import="java.sql.Connection" %>
<jsp:useBean id="val" scope="request" class="Gov.Cdc.Dbmd.Lits.validatebean"/>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
//Checking the username and password is null
if(username == null || password == null || (username.trim()).length() == 0 || (password.trim()).length() == 0)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="1" />
</jsp:forward>
<%
}
else
{
//Check whether the Driver is already Installed in your Hard Disk.
boolean check_flag = val.checkDriver();
if(!check_flag)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="5" />
</jsp:forward>
<%
}
//Check whether the Database Connection created was Valid for the web user.
boolean connection_flag = val.createConnection(username.trim(),password.trim());
if(!connection_flag)
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="4" />
</jsp:forward>
<%
}
//Check if the user id exists in the database.
int count = val.checkuser(username);
if(count == 0)//User Id does not exists
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="1" />
</jsp:forward>
<%
}
else//User Id Exists
{
int user_status = val.getUserStatus();
if(user_status == 0)//Inactive User
{
%>
<jsp:forward page="login.jsp">
<jsp aram name="msg" value="6" />
</jsp:forward>
<%
}
else if(user_status == 1)//Active User
{
session.setAttribute("username",username.trim());
session.setAttribute("password",password.trim());
session.setAttribute("sessionid",session.getId());
int admin_status = val.getAdminStatus();
if(admin_status == 0)//Ordinary Web User
{
%>
<!-- The Problem is here....--><jsp:forward page="linelistreport.jsp" />
<%
}
else if(admin_status == 1)//Web Admin User
{
%>
<!-- The Problem is here....--><jsp:forward page="user_settings.jsp" />
<%
}
}
}
}
%>
Hi Just now i saw one more thing....
if i am using response.sendRedirect() method then the session variable value will be lost giving null value so in next page it will automatically take me to first login page.then once again if i enter the same userid and password then now the session variable is having the values userid and password it will go the exact destination page.
what i am doing wrong in this code.can you tell me???
[ June 25, 2002: Message edited by: Kumaran Sowrirajan ]
15 years ago
JSP
Hi Friends
I need a solution for this doubt...
I am having 2 jsp files called file1.jsp and file2.jsp.
In file1.jsp i am getting the userid and password from the login page and stored that values in session variables.
If i click the submit button in file1.jsp page it will goes to next page file2.jsp there i am doing some validation based on the UserId and return back to the file1.jsp page and show the results to web user.
Here in file2.jsp what i am doing is i put the variables [userid and password] in Session like and redirect to the file2.jsp page for processing and validating some other conditions based on userid.
storing the values using session.setAttribute("name","value");
fetching the values using session.getAttribute("name"); methods.
Then from file2.jsp i am redirecting to the file1.jsp using response.sendRedirect() method to show the results.
here is the problem for me only in netscape4.76
If i use the response.sendRedirect() method from file2.jsp then the values in the session variables will be lost. But the same code is exactly working IE5.0 and above and even in Netscape 6.0.
But if i use the jsp:forward method instead of response.sendRedirect() method then mine code is working in netscape.can any of you knows the exact problem.what i am doing wrong here???
I gave both the absolute path as well as the relative path in the response.sendRedirect() method as a parameter.
Remember the same code is working in IE and in Netscape Navigator 6.0 but not in Netscape Navigator 4.76.
Thanks
Kumaran.S
15 years ago
JSP
Hi friends
I am having 5 jsp pages.each jsp page contains
one Javabeans in which database
connection and relevant results are fetched from the database and the results are returned to
the corresponding jsp page.so if i succesffuly logged into my application then for each jsp
page i am accessing the javabeans which will connect to the database connection and return the
valid results.this will make the response slow.
[i think for each request i am opening the database connection and fetch the results and
return the results to the corresponding jsp page and close the database connection this will
make the response time slow.am i correct???]
What i want to know is how can i make the database connection open whenever the user session
starts and connection remains open until the session is valid for the particular user.suppose
if the session is invalid then the database connection should be closed.
[bcos now if you access any jsp pages then the response time is quick compared to previous one.]
I dont want to open a database connection everytime if i am accessing the jsp page and closed
after the user leaves the page?is it possible thro' connection pooling???
I am using jdbc-odbc driver to connect to the database.is it possible to do like that???
if so...then plz tell me how to do that one???
Also which one is best to access the database records???Servlets or in JavaBeans and why?
Also i am coming across one more problem which is better to use???Vector or Hashtable to fetch
the records from the database.more accurately which is faster?i know Vector is synchronized so
it is not faster compared to arrays.then is there any java.util.collection is there to increase
the fetching the data very fastly.
Thanks
Kumaran.S
16 years ago
JSP