Making an Input Button

R

RigasMinho

Hello,
I have a java application where i have this source code in the JSP
file.
<input type="submit" name="add" value="Add User">
<input type="text" name="newadmin" size="30"
onChange="javascript:fillSubs(this.form)"><br>

I want it so that when you put in an e-mail address it adds the text
in the box to become a member of an administrator of the application.

The guy did it pretty bad before me - he hard coded in source code to
make administrators work by using this function:

TreeSet admins = new TreeSet();
admins.add("(e-mail address removed)");

And that basically adds the admin to the application. The application
then realized that user is logged in and gives admin rights to the
user.

So at the end basically i'm trying to make it so that we can add
admins to the application with out changing the source code manually
and then saving it - then creating a war file - then deploying it to
websphere.

I thought about making it read from a text file but no idea how to
start that. Unless you guys think its easier - he does have this in a
java file...
public static synchronized String[] getLdapToolAdmins()
{
int _LTAdminCount =
Integer.parseInt(_inifile.getProperty("AdminCount"));
String temp[] = new String[_LTAdminCount];
for(int i = 0; i < _LTAdminCount; i++)
{
temp =
_inifile.getProperty("LTAdmin".concat(String.valueOf(String.valueOf(i))));

}

return temp;
}

BUt somehow that doesnt really add admins to the application because
the file i have lists the admins to the app but doesnt get loaded in
somehow.

Any ideas?
 
L

Lew

RigasMinho said:
Hello,
I have a java application where i have this source code in the JSP
file.
<input type="submit" name="add" value="Add User">
<input type="text" name="newadmin" size="30"
onChange="javascript:fillSubs(this.form)"><br>

I want it so that when you put in an e-mail address it adds the text
in the box to become a member of an administrator of the application.
So at the end basically i'm trying to make it so that we can add
admins to the application with out changing the source code manually
and then saving it - then creating a war file - then deploying it to
websphere.

Typically one would do this with a database or LDAP / JNDI interface.

Pass the data to a data access object (DAO) that uses JNDI or JDBC to post the
data to the data store.

Then go into the authorization mode, where the system looks up the (possibly
just entered) information to decide authorization.

- Lew
 
R

RigasMinho

Typically one would do this with a database or LDAP / JNDI interface.

Pass the data to a data access object (DAO) that uses JNDI or JDBC to post the
data to the data store.

Then go into the authorization mode, where the system looks up the (possibly
just entered) information to decide authorization.

- Lew

Awww man that sucks - i have no idea what you're talking about too :)
 
L

Lew

Awww man that sucks - i have no idea what you're talking about too :)

I am sorry. Let me attempt this from a different angle, and if I don't make it
clear perhaps others will nail it better than I. Also, if you have a specific
question about something I said, let me know. It will help me to make my
explanation clearer.

You say you want to take input from a JSP (i.e., HTML) text field and put it
into your system in a way that lets the system refer to that input. In this
case, you want to take the identifier (name, email address, Top Gun nickname)
of an administrator and add it to some sort of knowledge base (source code,
the way you described it). Later, the application should recognize that
identifier as an administrator, and grant the user the authorization to do
magical administrator things.

Is that right?

Source code is a *terrible* place to store data. As you point out, it causes
you to rewrite the application every time the data change, in this case, the
list of administrator identifiers. This sin is called "hard coding" the data.

So if source code is the wrong place to base your data, where should you base
your data? Base it in some data place, perhaps, oh, like, say, a data base.

Or a text file. Or a special kind of text file, like an XML file. Or a
spreadsheet. Or a special kind of data storage called "LDAP".
(Lightweight Directory Access Protocol,
<http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol>
)

The point is, the storage place for data, also called a "data store", is in
some storage medium that is not the Java code (neither source nor byte). Then
your Java code, which is a set of instructions, can instruct the computer to
accept the information sent by the browser, notice that the command is to
"Add" an administrator, and store the data in the data store. No code rewrite
needed.

- Lew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top