aspose file tools*
The moose likes JSP and the fly likes How to get Browser Variable value in side JSTL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "How to get Browser Variable value in side JSTL" Watch "How to get Browser Variable value in side JSTL" New topic
Author

How to get Browser Variable value in side JSTL

Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Hi All,

A little problem am facing.
I done know how I will get a users entered username and password from the form in browser and put the value in JSTL tag.
I have tried quite a fre but got invalid datasource errors.
Please help me get out of this.
My code is like below:

If i put the real values then its working and its taking the datasource.
I want it to take the value from the form where user specifies its value.

In regular i do



Please help what should i put in the datasource so that it will take the session values provided by user.


Regards, Ricky
Oracle Weblogic 10g Certified Expert TechPaste.Com
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Any Help Friends!!!

I just want to replace the hardcoded username, password,DBurl with values given by users in a form which i take as t11,t22,t33,etc.
How to do it.

Please help!!

Thanks
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Use EL like {$requestScope.t11} .. etc.
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Ohh Thanks,

I did that I have ELAPI jar also. but I am getting below error but if I remove the requestScope and give direct username and password its retuning results please help me what shall i do.
In Form


My Code:


ERROR:



If i hardcode the username password in the tag its giving me output with out the error .
And I'm also able to login through sqlplus using the username and password.

Please help!!!
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Ramakanta,

Did you print out first and check if {$requestScope.t11} is returning what you expected and sent in form ? There might be additional spaces that might have added.
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Hi Balu I just tried below and results are,
tried with below code


It shown me nothing
no values


Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874



Ramakanta,

You have misunderstood the basic concept here.JSPs, servlets are executed in the server side.You got both your codes (input text box) and request parameter to print out in the same JSP ?

It will return nothing (no values ) because when your JSP is called , you do not have t11 in requestScope , which is yet to be rendered as HTML to the user.

So the flow should be call a input.jsp where you get the username and submit to query.jsp , where you print it out requestScope.t11 and use it in sql tags.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Ramakanta Sahoo wrote:
My Code:



Check that in this line:
driver="oracle.jdbc.OracleDriver" url="jdbc:oracle:thin:@db1host1:1522:MY03DB" user='{$requestScope.t11}'
you are setting to the user {$requestScope.t11} and I don't think that is allowed, try ${requestScope.t11}

Also take care about what Balu has told you about doing all in the same page.
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Hi All,

Thanks A lot for the timely help extended.

As suggested I made 2 files querydb.jsp and getquery.jsp
but still i am facing a issue like below and again if i hardcode it it works fine. May be I am missing something please suggext what to do.

querydb.jsp


getquery.jsp



ERROR


Is requestScope is correct way/syntax to get session inputs.

Please help!!
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Yes, that is correct, if you want to see which value has it you can try to print the ${requestScope.t11} (you can cut the <sql: line for allowing the jsp to be shown)

How are you submitting the form? I donĀ“t see any button or something like that...
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

Sorry I didnt put it in here.

Cut the SQL what you want me to do.?? I didnt get it.
I did a sqlut it didnot print anything.
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Ok, have you tried to do what I told you about printing the t11 var?
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254



Both DIDNOT give me any output
Ramakanta Sahoo
Ranch Hand

Joined: Aug 23, 2008
Posts: 254

My GoodNess I wasted so much of time in posting...
I got dragged into somany things....

Just puttting the solution for reference..

we need to set the values taken as input before proceeding to next page.

we need to do something like below then only it will work and it will take the varibales to next page.



other page just call



it will give you param's

now i want to concatinate my dburl as its in different parts like t44=SID,t55=Hostname,t66=portnumber
If some one knows how to then please post.

thank you
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Oh!!

F*** I am preatty new to JSTL an EL but I have been working with it the last weeks...
Albareto McKenzie
Ranch Hand

Joined: Apr 08, 2009
Posts: 298
Maybe you can do something like:



And I think I am going to bed xDDDDD

Good luck!
 
jQuery in Action, 2nd edition
 
subject: How to get Browser Variable value in side JSTL