Kunal Lakhani wrote:If i place An attribute 'Id' in radio buttons in Login.jsp, how can i get this Id when the radio button is selected??
You get the value of the selected radio button when you call request.getParameter(). Did this not work?
Also when you convert to the real project, be sure to use PreparedStatements and binding variables to prevent SQL Injection. Right now someone can delete the contents of the whole database table or login without a proper password.
request.getParameter("r1") obviously won't work directly, because the value of r1 being submitted is "Staff", for both Journalist and Reporter.
It seems that this parameter is being used to figure out which table to query. That whole building up the query with string concatenation leaves you wide open for SQL injection attack as has been mentioned.
You need to change your radio button values so that you can distinguish between them.
Maybe something like the following:
But then of course you won't be able to use the value of r1 for the table name any more.....
So maybe a mapping between these values, and what the table/column values for it are?