aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes session in desktop application? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "session in desktop application?" Watch "session in desktop application?" New topic
Author

session in desktop application?

Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 995
    
    2
hello , i create a desktop application, when user run that, a login screen appears, and only after successful login he will get access to that software.
but i want afetr user logged in, if he again run that application he should not get login screen again.
so what can i do for this, sessions are there in desktop applications??
also i want to know my login code is okay or not, here is my login code:



Thank you.
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
also i want to know my login code is okay or not

It's not, it's wide open to SQL injection attacks. Read up on PreparedStatement.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10247
    
    8

Punit Jain wrote:
so what can i do for this, sessions are there in desktop applications??

No. But you can use the preference API


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Ranganathan Kaliyur Mannar
Bartender

Joined: Oct 16, 2003
Posts: 1076
    
  10

Your login code is very poor. You have declared a PreparedStatement and are calling 'prepareStatement' too, but it is a waste because there is nothing there to prepare in the query.

As for session, I don't think your definition of session is correct. Even in a web app, when I open the browser and log in, my 'session' is alive only till my browser is open. If I close the browser and re-open again, my session is lost and I have to re-login again. So, I think the same would apply to desktop too.

If you want the functionality that you have mentioned, you have to write your own logic, but don't call it a 'session'.


Ranga.
SCJP 1.4, OCMJEA/SCEA 5.0.
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 995
    
    2
okay i have done changes to my login code, here is what i changed:
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 995
    
    2
also with my earlier login code i just tried for sql injuction with below login id and password:

user:admin
pass:’ or 1=1–

but it showing me exception only, not giving my user id and password.??
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
How about this as a password:

'; drop table AdminLogin; --
Punit Jain
Ranch Hand

Joined: Aug 20, 2011
Posts: 995
    
    2
no it's not dropped my table, it showing me one exception:
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
Well, just keep at it and eventually you may succeed.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: session in desktop application?