Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

java application and url

  Asked By: Lydia    Date: Dec 22    Category: Java    Views: 999
  

I need to transfer password and username from my java application
page to a jsp page.
My code which changes from application to web page is:-


else if(event.getSource() == Button3)
{
BrowserControl.displayURL
("http://shivan:8080/invis/jsp/test/checkname.jsp?Tpid="+tempid+"");
}

where BrowserControl is another class declared public and
displayURL is declared a static void function.
checkname is the jsp page.
When Button3 is clicked the password and username has to be
transferred. I dont want to pass it as a query string.
Can someone help me?

Share: 

 

3 Answers Found

 
Answer #1    Answered By: Corey Brown     Answered On: Dec 22

I am not sure if you are using the right way . you may check the J2EE
templates for one or other ways that you may do that more effective.

As a short term solution you can encrypt the parameter values using a
server encryption key on the provider and decrypt it on the consumer
side.
In order to Encipher, decipher the strings you have different
alternatives. From simple own written classes that "Xors" the bytes to
deploying Public key cryptography algorithms using a JCA/JCE provider.

Xor way :

original-byte xor key = transmission-byte
transmission-byte xor key = original-byte

JCA/JCE Way:

read and get yourself informed about the java  security architecture. the
class you will use ( assuming you have a security provider
implementation deployed in your server framework) is
java.sun.com/.../Cipher.html

 
Answer #2    Answered By: Fred Hicks     Answered On: Dec 22

There is different way of passing information from
front end application(Applet and application)to the
middlewares( such as servlet and jsp).
you can use a javabean as a data container and fill
your information in it and write it to stream by using
diiferent method such "writeobject" and in the other
side use"Readobject" and get the pointer to the
object .The following code  will help  you.

Client side:


try
{
URL url=new URL(urlStr);
URLConnection con=url.openConnection();
con.setUseCaches(false);
con.setDoInput(true);
con.setDoOutput(true);
OutputStream out = con.getOutputStream();
ObjectOutputStream outStream = new
ObjectOutputStream(out);
outStream.writeObject(item);
outStream.close();
out.close();
InputStream in=con.getInputStream();
DataInputStream textStream=new DataInputStream(in);
textStream.close();
in.close();
}catch(Exception ex){
ex.printStackTrace() ;
}


server Side:

try{
InputStream in = request.getInputStream();
ObjectInputStream objStream;
objStream = new ObjectInputStream(in);
RequesterItem item= new RequesterItem();
item =(RequesterItem) objStream.readObject();
objStream.close();
in.close();

 
Answer #3    Answered By: Ludo Ricci     Answered On: Dec 22

You may try encrypting your pwd by an MD5 method:


import java.security.*;
...
 public  String getMD5(String givenStr) {
String result = null;
try {
byte[] data1 = givenStr.getBytes();
MessageDigest md5 = MessageDigest.getInstance("MD5");
byte[] bytes = md5.digest(data1);
result = new String(md5.digest(data1));
} catch(Exception e){
//do something
}
return result;
}

 
Didn't find what you were looking for? Find more on java application and url Or get search suggestion and latest updates.




Tagged: