Problem when passing string array in sessions showing null value
i am trying to pass a string array but it is showing me the null value
i think the the problem is seem to be in session.settAttribute("subject['"+i+"']",subject) in 2.login_action.jsp
or in String sub1=(String) session.getAttribute("subject[0]"); in 3.user_home.jsp
i have following three pages
1.login.html
2.login_action.jsp
3.user_home.html
1.login.html
<html>
<body>
<form method="post" action="login_action.jsp">
Username<input type="text" name="username"></input>
<br>
Password<input type="password" name="password"></input>
<input type="submit" value="login"></input>
</form>
</body>
</html>
2.login_action.jsp
<%@ page contentType="text/html"%>
<%@ page import="java.sql.*" %>
<%!
String user,pwd;
String subject[]=new String[10];
int i,totalsubject;
%>
<%
try
user=request.getParameter("username");
pwd=request.getParameter("password");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:ods","scott","tiger");
PreparedStatement ps = con.prepareStatement("select password from users where username='"+user+"'");
ResultSet rs = ps.executeQuery();
if(rs.next())
if(rs.getString("password").equals(pwd))
session.setAttribute("username",user);
PreparedStatement ps2 = con.prepareStatement("select subject_id from allot_teachers where staff_id='"+user+"'");
ResultSet rs2 = ps2.executeQuery();
while(rs2.next())
i=0;
subject[i]=rs2.getString(1);
// if i display here the subjects in out.println(subject[i]) it is working fine
// but in next redirected page it is showing null
session.setAttribute("subject['"+i+"']",subject[i]);
//out.println(subject[i]);
i++;
response.sendRedirect("user_home.jsp");
else
out.println("error invalid username or password");
else
out.println("error invalid username or password");
con.close();
catch(Exception e)
out.println(e);
%>
3. user_home.jsp
<%@ page contentType="text/html"%>
<%@ page import="java.sql.*" %>
<html>
<%
String user,pwd,cat,cat1;
String username=(String) session.getAttribute("username");
if(username==null)
response.sendRedirect("login.html");
//just tried for first two subjects
String sub1=(String) session.getAttribute("subject[0]");
String sub2=(String) session.getAttribute("subject[1]");
//here it is printing null
out.println(sub1);
//here it is printing null
out.println(sub2);
%>
<form method="post" action="logout.jsp">
<input type="submit" value="Logout"></input>
</form>
</html>
Cheers & Regards
sweety
The name in getAttributre doesnt match the name in setAttribute.
Note "subject[0]" is a string containing 10 chars, "subject" is a string containing 7 chars.
Here is your code:
session.setAttribute("subject",subject);
String sub1=(String) session.getAttribute("subject[0]");
Similar Messages
-
How to retrieve string array using Session?
Hi, I am having some problem retrieving string arrays through session.
String personalData[] = new String[17];
personalData = (String [])session.getValue("PersonalData");
The coding above isn't working. Advise pls.. ThanksThe getValue() method is deprecated - you should probably be using getAttribute.
What about this code isn't working? Looks ok to me, as long as the "PersonalData" object in the session is a String[] it should work.
Cheers,
evnafets -
Example of passing String Array from java to C using JNI
hi all
i searched net for passing string array from java to C but i dont get anything relevent
i have
class stu
int rollno
string name
String [] sub
i want to pass all as String array from java to C and access it C side1. Code it as though it were being passed to another method written in java.
2. Redefine the method implementation to say "native".
3. Run jnih to generate a C ".h" file. You will see that the string array
is passed into C as a jobject, which can be cast to a JNI array.
4. Write the C code to implement the method and meet the interface
in the generated .h file. -
'Show Null Values as' variables not replaced
I need the null values to display as small as possible so there is an image in my image repository, 1x1px, transparent, that I wanted to display in these null places, but when I inserted something like <img src="&COMPANY_IMAGES.null.gif"> or <img src="#COMPANY_IMAGES#null.gif">, the COMPANY_IMAGES was not replaced with the usual long call, it was just like inserted in the 'Show Null Values as' field.
I have workarounds
1) use a static image, that is publicly available - making the app's appearance dependant on that publicly available image.
2) select columns with nvl(NULLABLE_COL, '<img src="#COMPANY_IMAGES#null.gif">'), which is just a thing, that could be easily forgotten in some place and makes the query even more obscure than it already is.
I really like neither of them. Is there some other way to call COMPANY_IMAGES in that field or is it just a place where isn't the substitution string available?wow. you're right about that substitution not being made in that "Show Null Values as" field. i'll log that issue in a sec. you can work around the issue for now by simply doing that substitution yourself. so if you run this...
select :WORKSPACE_IMAGES FROM DUAL
...from your sqlWorkshop, you'll see that WORKSPACE_IMAGES is substituted with a call like...
wwv_flow_file_mgr.get_file?p_security_group_id=123456&p_fname=
...(where 123456 is my :WORKSPACE_ID). if you wanted to call an image called my_image.jpg in that "Show Null Values as" field, you could just enter the string...
wwv_flow_file_mgr.get_file?p_security_group_id=123456&p_fname=my_image.jpg
...right in there, and you'd find your images rendered correctly. the only thing to watch out for is the hard-coded :WORKSPACE_ID in your field. you'd have to mind at number if you deployed your app in a different workspace.
hope this helps,
raj -
Hi,
I am running Discoverer Plus 10.1.2.45.46c. We are running into some issues with the Show Null values as option under Tools/Options/Sheet tab. If you open an existing workbook that has this value set to NULL you can't change your output to show as ' ' for example.
Has anybody else ran into this ? Is there a work around ?
Thanks
DennisAs per bug 4330751 - workbooks created in desktop with the option for nulls set to "" will display as NULL in plus. There is a new worksheet setting for nulls that you can modify in plus - Edit->Worksheet Properties->Crosstab/Table Format tab.
The pref.txt setting will be honored for new plus workbooks. -
Problem with prepared statement where cluase when passing string value.Help
I am updating a table using the following code. I am using string parameter in where clause. if I use Long parameter in where clause with ps.setLong , this code is working. Is there any special way to pass string value? Am I doing anything wrong?
===================
updateMPSQL.append("UPDATE MP_Table SET ");
updateMPSQL.append("MPRqmt = ?,End_Dt = ? ");
updateMPSQL.append("where POS = ? ");
System.out.println(updateMPSQL.toString());
con = getConnection(false) ;
ps = con.prepareStatement(updateMPSQL.toString());
ps.setLong(1,MPB.getMPRqmt());
ps.setDate(2,MPB.getEnd_Dt());
ps.setString(3,MPB.getPos());
result = ps.execute();
System.out.println("Result : " + result);
==========
Please help me.
Thanks in advance.
Regards,
Sekhardoesn't Pos look like a number rather than a string variable?
if I use Long
parameter in where clause with ps.setLong , this code
is working.
updateMPSQL.append("where POS = ? ");
ps.setString(3,MPB.getPos()); -
Not enough memory error when passing an array to a chart
Hello.
I am trying to pass some data from a reading loop to a display loop using queues and charts.
In order to save on redraws I am reading the queue just once a while, flush it and pass the resulting array to the Chart. It is actually an array with clusters of three values.
Everything works fine unitl I actualy want to display the chart. I can pass the data and see it using an indicator without any problems.
When I wire the data to the chart it randomly shows : "not enough memory to complete this operation"
The fact is the array being passed to the chart is of random size.
The queue size is good for about 20 min. Labview shows an error after a few seconds. After clicking ok it prints out the results correctly and then a second or two later same error.
What am I missing here? Thanks
LV 2012 f3 I7 2.4GHz 16GB RAM
Attachments:
TestChart.vi 17 KBNot sure if it helps or not but here is the error.
I put about 200 elements/s in the queue. That is why instead of reading it 200/s I just want it to read it once a while.
I am not sure what is a bigger burden:copying one 500 elements array twice a second or 200/s and 200 calls to the Queue.
The max size of the queue is not important here. I can set it to something more reasonable and will get the same error.
What will happen to my CPU usage if I put the Chart in the for loop and make 500 call to it? And then half a second later another 500 calls?
As I said at this point I do not know how much history I need or not but all I want is to be able to see a few s of it. If I loose the rest it is ok for now.
Lets says that all I care is to see it close to real time with a history of 5s. It would mean the queue buffer size of 1000.
Back to the main problem: why do I see the memory error window when I know clearly that I have plenty of memory left.
Attachments:
Error.jpg 18 KB -
How to Pass String array from Java to PL/SQL and this use in CURSOR
hi,
I cant understand how to pass Array String as Input Parameter to the Procedure and this array use in Cursor for where condition like where SYMPTOM in( ** Array String **).
This array containing like (SYMPTOM ) to be returned from the java to the
pl/sql (I am not querying the database to retrieve the information).
I cannot find an example on this. I will give the PL/SQL block
create or replace procedure DISEASE_DTL<*** String Array ***> as
v_SYMPTOM number(5);
CURSOR C1 is
select distinct a.DISEASE_NAME from SYMPTOM_DISEASE_RD a
where ltrim(rtrim(a.SYMPTOM)) in ('Fever','COUGH','Headache','Rash') ------- ***** Here use this array element(like n1,n2,n3,n4,n5..) ******
group by a.DISEASE_NAME having count(a.DISEASE_NAME) > 3 ----------- ***** 3 is no of array element - 1 (i.e( n - 1))*****
order by a.DISEASE_NAME ;
begin
for C1rec IN C1 loop
select count(distinct(A.SYMPTOM)) into v_SYMPTOM from SYMPTOM_DISEASE_RD a where A.DISEASE_NAME = C1rec.DISEASE_NAME;
insert into TEMP_DISEASE_DTLS_SYMPTOM_RD
values (SL_ID_SEQ.nextval,
C1rec.DISEASE_NAME,
(4/v_SYMPTOM), --------**** 4 is no of array element (n)************
(1-(4/v_SYMPTOM)));
end loop;
commit;
end DISEASE_DTL;
Please give the proper solution and step ..
Thanking you,
AsishI've haven't properly read through your code but here's an artificial example based on a sql collection of object types - you don't need that, you just need a type table of varchar2 rather than a type table of oracle object type:
http://orastory.wordpress.com/2007/05/01/upscaling-your-jdbc-app/ -
Hi,
I m trying to pass a String Array to a DLL, but I can't found the type for the "Char *heihei[ ]"
Here I attached the screenshot here. Hopefully some expert here can help me to solve out this thing. Thanks a lot in advance.
DLL input:
int __stdcall RunDLLUI (char * pszMainPath, char * pszFileName, int * nArrayErrorRow, char * pszArrayErrorCol[], int nNumOfErrors, int nOffsetError);
Please refer to the pictures attached. Thanks again for your time.
Attachments:
code.JPG 29 KB
front.JPG 40 KB
DataType.JPG 49 KBYou should post your LabVIEW question to the LabVIEW board.
-
Pass String Array to Another JSP
Hi,
I want to pass a string array to a nother JSP. Could any one pls tell me whether this is possible in JSP,then how. If it's impossible how can i full fill my task.
Thanks,
Dumindu.Depends on how you are navigating from one jsp to the other.
For ex: if you are using a forward
in jsp1
sthinglike
String[] strArray = new String[]{"val1","val2","val3"};
request.setAttribute("arrayatt",strArray);in jsp it can be retrieved as
String[] ret = (String[])(request.getAttribute("arrayatt"));
Hope that helps -
Passing String Which Has Single Quote Row/Value to a Function Returns Double Quoate
Hi, I'm getting weird thing in resultset. When I pass String which has single quote value in it to a split function , it returns rows with double quote.
For example following string:
'N gage, Wash 'n Curl,Murray's, Don't-B-Bald
Returns:
''N gage, Wash ''n Curl,Murray''s, Don''t-B-Bald
Here is the split function:
CREATE Function [dbo].[fnSplit] (
@List varchar(8000),
@Delimiter char(1)
Returns @Temp1 Table (
ItemId int Identity(1, 1) NOT NULL PRIMARY KEY ,
Item varchar(8000) NULL
As
Begin
Declare @item varchar(4000),
@iPos int
Set @Delimiter = ISNULL(@Delimiter, ';' )
Set @List = RTrim(LTrim(@List))
-- check for final delimiter
If Right( @List, 1 ) <> @Delimiter -- append final delimiter
Select @List = @List + @Delimiter -- get position of first element
Select @iPos = Charindex( @Delimiter, @List, 1 )
While @iPos > 0
Begin
-- get item
Select @item = LTrim( RTrim( Substring( @List, 1, @iPos -1 ) ) )
If @@ERROR <> 0 Break -- remove item form list
Select @List = Substring( @List, @iPos + 1, Len(@List) - @iPos + 1 )
If @@ERROR <> 0 Break -- insert item
Insert @Temp1 Values( @item ) If @@ERROR <> 0 Break
-- get position pf next item
Select @iPos = Charindex( @Delimiter, @List, 1 )
If @@ERROR <> 0 Break
End
Return
End
FYI: I'm getting @List value from a table and passing it as a string to split function.
Any help would be appreciated!
ZKfixed the issue by using Replace function like
Replace(value,'''''','''')
Big Thanks Patrick Hurst!!!!! :)
Though I came to another issue which I posted here:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/a26469cc-f7f7-4fb1-ac1b-b3e9769c6f3c/split-function-unable-to-parse-string-correctly?forum=transactsql
ZK -
Problem in sending drop down list value to jsp page showing null value
i am trying to send a drop down list value from client side to a jsp page but getting null value
this is first page where i have accessed data from database and putted it in a drop down list
<select name="sub">
<%
while(rs2.next())
cat=rs2.getString(1);
%><option value="<%=cat%>"><%=cat%></option><%
}%></select>
<input type="submit" value="Go"></input>
now on submit i am going to another page
where i want the selected value from drop down list to be printed
i have used there
<%
String subject= request.getParameter( "sub.value" );
out.println(subject);
%>
but it is printing null here what is the problem that i m facing
thanx & reagrds
sweetyhow to generate dynamically names for text boxes
i am generating text boxes in while loop when selecting data from database
while(rs1.next())
name=rs1.getString(1);%>
<tr>
<td>1</td>
<td><%out.println(name);
//i am printing here stud_id a unique key and want to update records from following text boxes to particular stud_id
%></td>
<td><input type="text" name="????"></input></td>
<td><input type="text" name="????"></input></td>
<td><input type="text" name="????"></input></td>
<td><input type="text" name="????"></input></td>
</tr><%
the structure is like
stud_id | attended theory | conducted theory | ateended practical | conducted practical
where attended theory, conducted theory............. are to be inputed manually for all students and then update in database
so i am facing problem in generating names for textboxes how to do that
so that those can be updated in database for particular student
Thanx & Regards
sweety -
How to show NULL value when import data into excel
when retrieve data from sql server and import these data into excel.
data source is like : select a ,b c from tab
if a,b,c is nullable. when import these NULL value into excel, it becomes blank value, there is nothing in the excel cell.
if i don't want to use select isnull(a,'NULL') as a to convert the values.
what's else can i do to make it? is there a way to prevent changing the NULL to blank ?
or is there an easy solution to replace all the blank value to NULL in the excel ?help me ~
-
Error in Open Dataset. Application server file shows null value .
Dear Gurus,
As with my previous problem, I am now getting value from SAP Directory in AL11. But problem is-
1. When I try to get Quantity or Currency field, it shows runtime error while uploading in App. Server. So, I used Char data type variable to store currency field and concatenate these in a string type variable.
LOOP AT it_mseg INTO wa.
move it_mseg-erfmg to amount. " amount is a char type variable.
CONCATENATE it_mseg-mblnr it_mseg-mjahr it_mseg-matnr amount it_mseg-werks it_mseg-lgort INTO ld_string.
TRANSFER ld_string to filename.
But I am getting only 0 for all the records. If I directly transfer wa to filename, it shows values. But when i am passing string, all value shows 0. Plz give me solution.
Thanks,
With regards,
Tripod.Hi,
use
WRITE it_mseg-erfmg to amount.
or, assuming that the currency is WW_WAERS,
WRITE it_mseg-erfmg CURRENCY WW_WAERS to amount. -
DBA_USERS showing null values in PASSWORD column
Hi,
We are running a select query from dba_users table as follows :
select username from dba_users
where to_char(expiry_date, 'DD-MON-YY') =
to_char(sysdate + &expire_day, 'DD-MON-YY')
and password not in ('EXTERNAL','account-locked')
and account_status <> 'LOCKED';
This query was running fine with 10g Version, but after Oracle was upgraded to 11G recently, above query does not return any rows.
Also, when we remove the condition "and password not in ('EXTERNAL','account-locked')", it works.
And the values for the PASSWORD column shows null.
Is this related to Oracle upgrade ?
Kindly help..
Thanks,
JatinI have the same behavior in my 11g db (I have nulls in password column too) as checking docs:
[url http://download.oracle.com/docs/cd/E11882_01/server.112/e24448/statviews_5081.htm#REFRN23302]Oracle® Database Reference 11g Release 2 (11.2) - DBA_USERS
I can see:
USER_USERS describes the current user. This view does not display the PASSWORD, PROFILE, PASSWORD_VERSIONS, EDITIONS_ENABLED, or AUTHENTICATION_TYPE columns....
PASSWORD VARCHAR2(30) This column is deprecated in favor of the AUTHENTICATION_TYPE columnIt seems you need to get this info from somewhere else.
Edited by: Kecskemethy on Oct 3, 2011 2:36 AM
Maybe you are looking for
-
My iPod touch is not detected on iTunes! HELP!!!!
Recently, there were some problems with my computer's wires' connections, so I had to buy a new extension and reconnect everything. I don't know if it has something to do with the problem. I just mentioned it, just in case. Yesterday, when I tried co
-
my ipad mini ID code is forgetten, and its system is also broken and how to change the ID and restore the system?
-
Magic Mouse preference panel missing
I just put a magic mouse into operation and while it is "working" it is not doing some things I want it to and I am unable to change any settings because the "Mouse" preference panel has not changed to a dedicated "Magic Mouse" pref panel. All the Mo
-
PPOSE to OrgPublisher: How to have position descr. instead of job descr. ?
Hi, I'm using tx PPOSE and I have the application OrgPublisher installed on my PC. This invokes an extra button available in PPOSE: 'Format Structure Graphically'. Pressing this button sends a file to the pc, which opens in OrgPublisher. In this fil
-
I just tried to download the After Affect trial and got the following error:
Tried to find the path to the c++ file but a folder must be hidden. I am running Windows 8, any help appreciated... really wanna learn this stuff Also, how do you install After Affects on a different drive other than C:? Exit Code: 6 Please see sp