Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need a sugestion

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
Hi,

I'am developing an intranet in jsp and i want a sugestion for the permission of users and access contents policy.
I have a form that require 32 input fields. The problem is that for each user i want to define if the field could be text or hidden and what is in the field the default text.
For this i build a table with all the parameters defined for each user, like this:

User Field KeyField Default
.................................
test name 1 Richard
test country 0 portugal

....

I think set 32*3 parameters is not an good idea.
Anyone has an suggestion for do this?

Thanks
Ricardo
 
So for each of the users, there are 32 fields, but depending on who the users are, some fields are text, and some are hidden ?

I'm not sure what you mean quite by "I think set 32*3 parameters is not an good idea." Could you elaborate a bit ...

 
I think what i need is something like split a variable into 32 variables.
With this i could set all the permissions to one user using only one connection to the database.
How do i split ?

I try this code, but i only split to two. How can i split to more than two?

ArrayList ListaUtilizadores=form.getInterfaces();
for( int x=0;x<ListaUtilizadores.size();x++)
{
TblInterface qryUsr=(TblInterface) ListaUtilizadores.get(x);
String Perms = qryUsr.getCliente();
int splitLocation = Perms.indexOf(&quot;,&quot;);
String exString = Perms.substring(0,splitLocation);
int exInt = Integer.parseInt(Perms.substring(splitLocation+1, Perms.length()));
out.println(&quot;&quot; + exString + &quot;&quot;);
out.println(&quot;&quot; + exInt + &quot;&quot;);


Thanks
Ricardo
 
To split a String which is separated by a comma, you can do this :


Code:
java.util.StringTokeizer st = new java.util.StringTokeizer(myString, &quot;,&quot;);

while (st.hasMoreTokens()) {
   System.out.println(st.nextToken());
}

If you need to update a db with all these params, I would create a stored procedure in the db, which you could then update the db in one connection call used a CallableStatement ...
 
Ok, now i have

ArrayList ListaUtilizadores=form.getInterfaces();
for( int x=0;x<ListaUtilizadores.size();x++)
{
TblInterface qryUsr=(TblInterface) ListaUtilizadores.get(x);

StringTokenizer st = new StringTokenizer(qryUsr.getCliente(), &quot;,&quot;);

while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}


But what i need is the out.prinln of each String. This code do not show the Strings.
It is possible have something like st.Token(1),st.nextToken(2) ....

Thanks
Ricardo
 
Hi,

You can store the st.nextToken() into a String and add the value to the Array of String in the while loop and you use the Array in the JSP with all the tokens in it.

java.util.StringTokenizer st = new java.util.StringTokenizer(&quot;1,2,3,4,5&quot;, &quot;,&quot;);
String[] stringValues = new String[st.countTokens()];
int i = 0;
while (st.hasMoreTokens()) {
String tokenValue = st.nextToken();
stringValues = new String(tokenValue);
i++;
}

out.println(stringValues[0] + &quot;,&quot; + stringValues[1]);

Cheers,
Venu
 
Not work

[javac] ..\teste_jsp.java:74: incompatible types
[javac] found : java.lang.String
[javac] required: java.lang.String[]
[javac] stringValues = new String(tokenValue);
[javac] ^
[javac] 1 error
 
Hi,

Sorry, it should be

stringValues = new String(tokenValue);

Cheers,
Venu



 
Hey Sorry once again. It a ProcessTGML which was on While posting the Answer


Here you go it should be,
stringValues = new String(tokenValue);

Cheers,
Venu

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top