Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Accessing columns of table - Java server pages

Reply
Thread Tools

Accessing columns of table - Java server pages

 
 
Evrim
Guest
Posts: n/a
 
      08-18-2007
Hi

I have a JSP that builds a table and shows the values in fields according to
what has been passed to it through a request.setAttribute of a servlet.

For example the two dimensional array "test" has this data:

Col1 Col2 Col3
Row1 a b c
Row2 d e f



and JSP will read this from request variable and display it.

These values (a,d) are displayed as hyper links to a page testpage.jsp.

What I need to do is, when user clicks a , I need to set b and c in a
variable array and pass it to the next page , or when user clicks d I need
to pass e and f to next page.

1. Could you please tell me how to do that ?

2. Do I need Javascript ? or it can be done in Java? I prefer to have all
the code in Java.

3. How is it possible to access and change a request variable from
JavaScript ?


Appreciate your help in advance
Evrim


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      08-18-2007
Evrim wrote:
...
>For example the two dimensional array "test" has this data:
>
> Col1 Col2 Col3
>Row1 a b c
>Row2 d e f
>
>and JSP will read this from request variable and display it.
>
>These values (a,d) are displayed as hyper links to a page testpage.jsp.

...
'Row1, Col1'
<a href='thetarget.jsp?Col2=b&amp;Col3=c'>a</a>
....
'Row2, Col1'
<a href='thetarget.jsp?Col2=e&amp;Col3=f'>d</a>

>What I need to do is, when user clicks a , I need to set b and c in a
>variable array


'Variable array'? Why not simply include it as the
parameters of a (plain old) hyperlink?
...
>2. Do I need Javascript ? or it can be done in Java? I prefer to have all
>the code in Java.


Do it in HTML. Use whatever (server) side language you
like to generate the HTML, but leave JS out of it - it is an
unnecessary complication.

>3. How is it possible to access and change a request variable from
>JavaScript ?


Between pages? See above.
'In-place' in a single page - that would
require JavaScript.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.asp...neral/200708/1

 
Reply With Quote
 
 
 
 
Evrim
Guest
Posts: n/a
 
      08-18-2007

"Andrew Thompson" <u32984@uwe> wrote in message news:76dd6a85928af@uwe...

> 'Row1, Col1'
> <a href='thetarget.jsp?Col2=b&amp;Col3=c'>a</a>
> ...
> 'Row2, Col1'
> <a href='thetarget.jsp?Col2=e&amp;Col3=f'>d</a>
>



First of all thank you very much for your reply ....

In this case , I should have a java code that builds query string based on a
loop that goes through the 2-D array , correct ?
Any tips or reading material is extremely apprecited...


Evrim


 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      08-18-2007
Evrim wrote:
> "Andrew Thompson" <u32984@uwe> wrote in message news:76dd6a85928af@uwe...
>
>> 'Row1, Col1'
>> <a href='thetarget.jsp?Col2=b&amp;Col3=c'>a</a>
>> ...
>> 'Row2, Col1'
>> <a href='thetarget.jsp?Col2=e&amp;Col3=f'>d</a>
>>

>
>
> First of all thank you very much for your reply ....
>
> In this case , I should have a java code that builds query string based on a
> loop that goes through the 2-D array , correct ?
> Any tips or reading material is extremely apprecited...


JSTL (JSP Standard Tag Library) and JSF (Java Server Faces) to the rescue,
specifically, EL (expression language).

<c:forEach items="${outer}" var="${thing}" >
<a href="thetarget.jsp?Col2=${thing.b};Col3=${thing.c }">
<cut value="${thing.a}" />
</a>
<br />
</c:forEach>

or some variation thereof. Nowadays, thanks to JSF, we'd prefer the enhanced
EL, that usually uses an octothorpe instead of a dollar sign to indicate an
expression:

<hutputText value="#{thing.a}" />

--
Lew
 
Reply With Quote
 
Evrim
Guest
Posts: n/a
 
      08-18-2007
Thank you for your reply ... I will try implementing it the way you
suggested.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing values according to fields in a table - Java Server Pages Denis Java 0 04-25-2007 04:53 AM
Align table columns with gridview columns Jacksm ASP .Net 2 11-21-2006 09:49 PM
database columns vs. gui columns and sorting ittay.dror@gmail.com Java 5 03-04-2006 10:48 AM
CSS columns problem - faux columns don't work henrybranson@hotmail.com HTML 4 11-24-2005 10:05 AM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM



Advertisments