Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameter String

Status
Not open for further replies.

DB2Problem

Programmer
Oct 17, 2002
53
US
Hello,

I have a java program and i am passing parameters

For Example -

paramName = "ABC & DEF";

when I am getting the values from the parameter. It is shown as

"ABC"

Please advise, I tried to encode it using URLEncoder.encode("string") BUT it did not work

Thanks,
 
Perhaps you could tell us where this parameter is set, and also accessed ?!

--------------------------------------------------
Free Database Connection Pooling Software
 
Well, it's set in the param tag of previous jsp page and when submitted, i am trying to get the same value..instead i am getting the truncated one..
 
That still doesn't really help us ....

Do you know the "param tag" (whatever that is) is setting the *value* correctly ?

How are you accessing this object and parameter. Via the HttpSession, or via the HttpServletRequest object or what ?

Crypic questions help no-one ! Try to post some specific code where you set and retrieve these parameters (please don;t post hundredds of lines of code - just the specifics).

Have you tried debugging your code (ie test the input parameter, where the parameter is set, and then retrieved) ?

--------------------------------------------------
Free Database Connection Pooling Software
 
Here is the first jsp page and second jsp page is used to gather the parameter submitted from the first page -

<%@ page import ="java.net.*" %>
<html>
<head>
<title>Test</title>
</head>
<body>
<script language="Javascript">
<!--//
function sendForm( f) {
f.submit();
return true;
}
//-->
</script>
<% String paramName= "ABC & DEF"; %>
<form name="f" method="post" action="test2.jsp" onClick="return sendForm(f)">
<input type="hidden" name="VehicleName" value="<%= paramName %>">
<input type="submit">
</FORM>
</body>
</html>

========================

<%@ page import ="java.net.*" %>
<%
String VehicleName = request.getParameter("VehicleName");
%>

<html>

<head><title> test page</title></head>

<body>

<b> <% out.println(VehicleName); %> </b>
</body>
</html>


Can someone tell me do i need to encode the parameter from my first jsp page. I am getting different result, so please tell me why is this working fine (even without encoding)
 
That test works fine for me (using tomcat 5) ...

"ABC & DEF" is successfully retrieved on the second page.

PS, you don't need to import java.net, nor do you need JavaScript to submit a form when you have a "sumbit" button in the form.


--------------------------------------------------
Free Database Connection Pooling Software
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top