aspose file tools*
The moose likes JSP and the fly likes JSP - Passing a string through URL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP - Passing a string through URL" Watch "JSP - Passing a string through URL" New topic
Author

JSP - Passing a string through URL

Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
Hello
I am having trouble passing a string from JSP through URL to another JSP. For some reason the string is null I have attched the relevant bits of code below... Please help...

First JSP
--------------------------
...
<%
List aList = new LinkedList();
String createEmployeeURL = "MaintainEmployee.jsp?pageSource=Create&employees="+aList;
%>
<a href=<%= createEmployeeURL %>>
<b>Create A New Employee</b>
....
The LinkedList is empty. That is fine. its the pageSource String I am having difficulty with.
---------------------------------
Second JSP
--------------------------------
<jsp:useBean id="employees" class="java.util.LinkedList" scope="request"/>
<jsp:useBean id="pageSource" class="java.lang.String" scope="request"/>
....
<%
String pageMode = (String)request.getAttribute("pageSource");
%>
For some reason String pageMode is empty....
Would appreciate anyhelp on this matter...
Regards,
Gajan
maneesh subherwal
Ranch Hand

Joined: Aug 26, 2002
Posts: 42
Try request.getParameter("pageSource") instead.
Thanks,
Maneesh


Sun Certified Java Programmer 2 (1.4)<br />Sun Certified Web Component Developer
Gajan Raj
Greenhorn

Joined: Sep 19, 2003
Posts: 12
Thanks Manesh...That worked.
Kaustubh Patil
Ranch Hand

Joined: Aug 13, 2001
Posts: 164
Originally posted by Gajan Raj:
Thanks Manesh...That worked.

Gajan,
Just to add to the discussion. The problem why you were not getting the variable using the <usebean> tag is :
Whenever you instantiate a variable using the usebean tag and request as a scope it particulary looks for the objects in the requests. The equivalent of this would be request.getAttribute(). But what you are doing now is passing the params by query string. So the values that you are passing are not accessed as objects in the requests but simply as name-value pairs.
So these can be accessed using request.getParameter().
-Kaustubh


Kaustubh. Mumbai, India.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP - Passing a string through URL