JSP

It is possible to disable the the submit button using JSPfor example button has name turn_on_update.The button should be enabled for admin person otherwise it should be disabled.please help with sample code
[234 byte] By [dilipsrma] at [2007-11-27 1:36:30]
# 1
how u identify the user logged in is administrator or other user?
kamal_shana at 2007-7-12 0:46:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
if (request.isUserInRole("admin")) by this command we can identify the whether the admin has logged or not we can get it.how the button can be disabled .please help with sample code
dilipsrma at 2007-7-12 0:46:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

After user logged-in, query and find out the user's role. If he is admin, using setAttribute set the value. Then in JSP using getAttribute, get the value and disable the button.

<% if (user.equalsIgnoreCase("admin")) {

String val = (String) request.getAttribute("role");

add DISABLED property in the button....

}else{

%>

put the button here which is not disabled...

<%}%>

skp71a at 2007-7-12 0:46:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

That is not so hard :)

Simple example:

<form action="test.jsp" method="post">

<input type="text" name="address" />

<input type="text" name="number" />

<%

if( request.getAttribute("user").getUserName().equals("admin"))

{

%>

<input type="submitAdmin" value="Insert new address and number" />

<%

}

else

{

%>

<input type="submitUser" value="Search for address and number" />

<%

}

%>

</form>

radicjesa at 2007-7-12 0:46:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5

<%

if(check the logged in is administrator)

{%>

<input type = submit value="somevalue" disabled>

}

else

{%>

<input type = submit value="somevalue">

<%}%>

%>

i think it works

kamal_shana at 2007-7-12 0:46:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...