Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

HTML onclick, session.setAttribute and jsp:forward

843836Jul 1 2004 — edited Jul 1 2004
Hi,

I've been trying to create a button/link that would forward to a new page with a few objects that I would like to pass along.

I have tried this:
<INPUT TYPE="IMG" SRC="next.gif" ONCLICK="session.setAttribute(\"attr1\",attr1); session.setAttribute(\"attr2\",attr2);<jsp:forward page='nextpage.jsp'>">
I manage to get the the next page, the nextpage.jsp being displayed in the browser addressbar, but I keep getting a NullPointer thrown back by Sun Applcation Server 8.

I have even tried using <%! %> to declare a method within the jsp to setAttributes, and tried using <FORM> tags with the action "submitform()" to no avail.

I need this done, as the intention is to have a column of buttons for a table, where a list is displayed. Upon clicking the button, the user will be provided with the details of the specific item.

Please help.

Comments

794117
Java/JSP = Server
javascript = client.

These things are not the same. They can not talk to one another.
This onclick event on the image runs on the client in javascript.
It can not invoke java/jsp code.

All Java/JSP code is executed. It produces an HTML page, which is sent to the client.
Then the client can run javascript, clicking buttons etc. No Java code (setting attributes etc) can be called.

The only communication javascript has with java is via submitting a form/request
ie nextpage.jsp?attr1=attrValue1&attr2=attrValue2
These parameters can only be strings.
There is no object communication between client and server - objects are stored on the server only.
intention is to have a column of buttons for a table, where a list is displayed. Upon clicking the button, the user will be provided with the details of the specific item
The correct way to do this would be to pass along an id identifying the item you want to display
eg Show Item details
Then in the showItem.jsp page retrieve an item using the parameter "56" and display its details.

Hope this helps,
evnafets


1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 29 2004
Added on Jul 1 2004
1 comment
1,038 views