• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to get Browser Variable value in side JSTL

 
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Use EL like {$requestScope.t11} .. etc.
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Balu I just tried below and results are,
tried with below code


It shown me nothing
no values


 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I didnt put it in here.

Cut the SQL what you want me to do.?? I didnt get it.
I did a sql:out it didnot print anything.
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, have you tried to do what I told you about printing the t11 var?
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Both DIDNOT give me any output
 
Ramakanta Sahoo
Ranch Hand
Posts: 256
Netbeans IDE Firefox Browser Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oh!!

F*** I am preatty new to JSTL an EL but I have been working with it the last weeks...
 
Albareto McKenzie
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe you can do something like:



And I think I am going to bed xDDDDD

Good luck!
 
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic