RE: request parameter question ...

2003-03-26 Thread Filip Hanik
that is what request.setAttribute is there for.

you can also look at JSP forward, that allows you to set parameters, not sure how this 
translates to a servlet

http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html


filip

> -Original Message-
> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 26, 2003 12:33 AM
> To: Tomcat List
> Subject: request parameter question ...
> 
> 
> Hi ,
> 
> In my servlet I have the following code:
> 
> String str = request.getParameter("name");
> 
> if(str.equals("xyz") == true)
> {
>   str = "ChangedName";
>   request.setParameter("name", str);   // 
> <- how  
> do i do this ??? There is no method as request.setParameter()
> }
> 
> try
> {
>   String path = "/SomeJSP.jsp"
>
> getServletConfig().getServletContext().getRequestDispatcher(pa
> th).forwar 
> d(request, response);
> }
> catch(Exception ex)
> {
>   ex.printStackTrace();
> }
> 
> one way to do it would be to append the parameter and its 
> changed value  
> to the path:
> String path = "/SomeJSP.jsp?name=str";
> 
> But is there some method like setParameter to do what I want to do ?
> 
> Thanks.
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: request parameter question ...

2003-03-26 Thread Erik Price


Mufaddal Khumri wrote:

if(str.equals("xyz") == true)
{
str = "ChangedName";
request.setParameter("name", str);   // <- 
how  do i do this ??? There is no method as request.setParameter()
}

[...]

one way to do it would be to append the parameter and its changed value  
to the path:
String path = "/SomeJSP.jsp?name=str";

But is there some method like setParameter to do what I want to do ?
You are looking for ServletRequest.setAttribute():

http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletRequest.html#setAttribute(java.lang.String, 
java.lang.Object)

Erik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: request parameter question ...

2003-03-26 Thread Mufaddal Khumri
Hi ,

I tried using

request.setAttribute("name", "newName");

try
{
	String path = "/SomeJSP.jsp"
	 
getServletConfig().getServletContext().getRequestDispatcher(path).forwar 
d(request, response);
}
catch(Exception ex)
{
	ex.printStackTrace();
}

When i do a request.getParameter in my JSP page .. it returns a blank  
sting "" . This is the reason I thought maybe request.setAttribute is  
not the method I should be using. Do you have any clues as to why this  
might be happening ?

Thanks

On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:

that is what request.setAttribute is there for.

you can also look at JSP forward, that allows you to set parameters,  
not sure how this translates to a servlet

http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html

filip

-Original Message-
From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 12:33 AM
To: Tomcat List
Subject: request parameter question ...
Hi ,

In my servlet I have the following code:

String str = request.getParameter("name");

if(str.equals("xyz") == true)
{
str = "ChangedName";
request.setParameter("name", str);   //
<- how
do i do this ??? There is no method as request.setParameter()
}
try
{
String path = "/SomeJSP.jsp"

getServletConfig().getServletContext().getRequestDispatcher(pa
th).forwar
d(request, response);
}
catch(Exception ex)
{
ex.printStackTrace();
}
one way to do it would be to append the parameter and its
changed value
to the path:
String path = "/SomeJSP.jsp?name=str";
But is there some method like setParameter to do what I want to do ?

Thanks.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: request parameter question ...

2003-03-26 Thread Erik Price


Mufaddal Khumri wrote:
Hi ,

I tried using

request.setAttribute("name", "newName");

try
{
String path = "/SomeJSP.jsp"
 
getServletConfig().getServletContext().getRequestDispatcher(path).forwar 
d(request, response);
}
catch(Exception ex)
{
ex.printStackTrace();
}

When i do a request.getParameter in my JSP page .. it returns a blank  
sting "" . This is the reason I thought maybe request.setAttribute is  
not the method I should be using. Do you have any clues as to why this  
might be happening ?
What happens if you try request.getAttribute() ?

Erik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: request parameter question ...

2003-03-26 Thread Mufaddal Khumri
I guess if i use setAttribute ... i have to use getAttribute ... thats 
the reason i get the blank string .. coz i was using getParameter

my problem is that the jsp uses getParameter ... it would have been 
good if i could have used the same method regardless as how the 
parameter was set.

On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:

that is what request.setAttribute is there for.

you can also look at JSP forward, that allows you to set parameters, 
not sure how this translates to a servlet

http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html

filip

-Original Message-
From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 12:33 AM
To: Tomcat List
Subject: request parameter question ...
Hi ,

In my servlet I have the following code:

String str = request.getParameter("name");

if(str.equals("xyz") == true)
{
str = "ChangedName";
request.setParameter("name", str);   //
<- how
do i do this ??? There is no method as request.setParameter()
}
try
{
String path = "/SomeJSP.jsp"

getServletConfig().getServletContext().getRequestDispatcher(pa
th).forwar
d(request, response);
}
catch(Exception ex)
{
ex.printStackTrace();
}
one way to do it would be to append the parameter and its
changed value
to the path:
String path = "/SomeJSP.jsp?name=str";
But is there some method like setParameter to do what I want to do ?

Thanks.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: request parameter question ...

2003-03-26 Thread Filip Hanik
then I would suggest to make your servlet into a jsp page, and that way you can use 
the jsp:forward to pass parameters

Filip

> -Original Message-
> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 26, 2003 1:02 AM
> To: Tomcat Users List
> Subject: Re: request parameter question ...
> 
> 
> I guess if i use setAttribute ... i have to use getAttribute 
> ... thats 
> the reason i get the blank string .. coz i was using getParameter
> 
> my problem is that the jsp uses getParameter ... it would have been 
> good if i could have used the same method regardless as how the 
> parameter was set.
> 
> On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:
> 
> > that is what request.setAttribute is there for.
> >
> > you can also look at JSP forward, that allows you to set 
> parameters, 
> > not sure how this translates to a servlet
> >
> > http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html
> >
> >
> > filip
> >
> >> -Original Message-
> >> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
> >> Sent: Wednesday, March 26, 2003 12:33 AM
> >> To: Tomcat List
> >> Subject: request parameter question ...
> >>
> >>
> >> Hi ,
> >>
> >> In my servlet I have the following code:
> >>
> >> String str = request.getParameter("name");
> >>
> >> if(str.equals("xyz") == true)
> >> {
> >>str = "ChangedName";
> >>request.setParameter("name", str);   //
> >> <- how
> >> do i do this ??? There is no method as request.setParameter()
> >> }
> >>
> >> try
> >> {
> >>String path = "/SomeJSP.jsp"
> >>
> >> getServletConfig().getServletContext().getRequestDispatcher(pa
> >> th).forwar
> >> d(request, response);
> >> }
> >> catch(Exception ex)
> >> {
> >>ex.printStackTrace();
> >> }
> >>
> >> one way to do it would be to append the parameter and its
> >> changed value
> >> to the path:
> >> String path = "/SomeJSP.jsp?name=str";
> >>
> >> But is there some method like setParameter to do what I 
> want to do ?
> >>
> >> Thanks.
> >>
> >>
> >> 
> -
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: 
> [EMAIL PROTECTED]
> >>
> >>
> >
> > 
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: request parameter question ...

2003-03-26 Thread Tam, Michael

getParameter is used to obtain data being pass by post or get method

set/getAttribute is used to access the data in the request object.

They are different.  You need to understand which one you do need.

Michael

-Original Message-
From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 1:02 AM
To: Tomcat Users List
Subject: Re: request parameter question ...


I guess if i use setAttribute ... i have to use getAttribute ... thats 
the reason i get the blank string .. coz i was using getParameter

my problem is that the jsp uses getParameter ... it would have been 
good if i could have used the same method regardless as how the 
parameter was set.

On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:

> that is what request.setAttribute is there for.
>
> you can also look at JSP forward, that allows you to set parameters, 
> not sure how this translates to a servlet
>
> http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html
>
>
> filip
>
>> -Original Message-
>> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, March 26, 2003 12:33 AM
>> To: Tomcat List
>> Subject: request parameter question ...
>>
>>
>> Hi ,
>>
>> In my servlet I have the following code:
>>
>> String str = request.getParameter("name");
>>
>> if(str.equals("xyz") == true)
>> {
>>  str = "ChangedName";
>>  request.setParameter("name", str);   //
>> <- how
>> do i do this ??? There is no method as request.setParameter()
>> }
>>
>> try
>> {
>>  String path = "/SomeJSP.jsp"
>>  
>> getServletConfig().getServletContext().getRequestDispatcher(pa
>> th).forwar
>> d(request, response);
>> }
>> catch(Exception ex)
>> {
>>  ex.printStackTrace();
>> }
>>
>> one way to do it would be to append the parameter and its
>> changed value
>> to the path:
>> String path = "/SomeJSP.jsp?name=str";
>>
>> But is there some method like setParameter to do what I want to do ?
>>
>> Thanks.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: request parameter question ...

2003-03-26 Thread Ron Day
Attributes and Parameters are different. Parameters only arrive as part
of a querystring or in a form post. Attributes are more general, and can be
set by the programmer. That said, they are set and read using different
methods. several responses to your post suggested using xxx?param=yy or
using a forward. Both these will set a parameter that you can read with
getParameter.

-Original Message-
From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 3:02 AM
To: Tomcat Users List
Subject: Re: request parameter question ...


I guess if i use setAttribute ... i have to use getAttribute ... thats
the reason i get the blank string .. coz i was using getParameter

my problem is that the jsp uses getParameter ... it would have been
good if i could have used the same method regardless as how the
parameter was set.

On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:

> that is what request.setAttribute is there for.
>
> you can also look at JSP forward, that allows you to set parameters,
> not sure how this translates to a servlet
>
> http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html
>
>
> filip
>
>> -Original Message-
>> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, March 26, 2003 12:33 AM
>> To: Tomcat List
>> Subject: request parameter question ...
>>
>>
>> Hi ,
>>
>> In my servlet I have the following code:
>>
>> String str = request.getParameter("name");
>>
>> if(str.equals("xyz") == true)
>> {
>>  str = "ChangedName";
>>  request.setParameter("name", str);   //
>> <- how
>> do i do this ??? There is no method as request.setParameter()
>> }
>>
>> try
>> {
>>  String path = "/SomeJSP.jsp"
>>
>> getServletConfig().getServletContext().getRequestDispatcher(pa
>> th).forwar
>> d(request, response);
>> }
>> catch(Exception ex)
>> {
>>  ex.printStackTrace();
>> }
>>
>> one way to do it would be to append the parameter and its
>> changed value
>> to the path:
>> String path = "/SomeJSP.jsp?name=str";
>>
>> But is there some method like setParameter to do what I want to do ?
>>
>> Thanks.
>>
>>
>> -
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: request parameter question ...

2003-03-26 Thread Erik Price


Mufaddal Khumri wrote:
I guess if i use setAttribute ... i have to use getAttribute ... thats 
the reason i get the blank string .. coz i was using getParameter

my problem is that the jsp uses getParameter ... it would have been good 
if i could have used the same method regardless as how the parameter was 
set.
There is a difference between the two methods, if you examine closely 
(at first they seem to be the same).  The [newer] *Attribute methods 
return Object whereas the [older] *Parameter methods return String.  You 
can see why the *Attribute methods are more flexible.

Erik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: request parameter question ...

2003-03-26 Thread Ron Day
Don't need to do this. You can use a requestDispatcher in servlet to perform
a forward (BTW: that's ultimately what a jsp relies on anyway !!)

Ron

-Original Message-
From: Filip Hanik [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 26, 2003 3:36 PM
To: Tomcat Users List
Subject: RE: request parameter question ...


then I would suggest to make your servlet into a jsp page, and that way you
can use the jsp:forward to pass parameters

Filip

> -Original Message-
> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 26, 2003 1:02 AM
> To: Tomcat Users List
> Subject: Re: request parameter question ...
>
>
> I guess if i use setAttribute ... i have to use getAttribute
> ... thats
> the reason i get the blank string .. coz i was using getParameter
>
> my problem is that the jsp uses getParameter ... it would have been
> good if i could have used the same method regardless as how the
> parameter was set.
>
> On Thursday, March 27, 2003, at 02:37  AM, Filip Hanik wrote:
>
> > that is what request.setAttribute is there for.
> >
> > you can also look at JSP forward, that allows you to set
> parameters,
> > not sure how this translates to a servlet
> >
> > http://java.sun.com/products/jsp/syntax/1.1/syntaxref1110.html
> >
> >
> > filip
> >
> >> -Original Message-
> >> From: Mufaddal Khumri [mailto:[EMAIL PROTECTED]
> >> Sent: Wednesday, March 26, 2003 12:33 AM
> >> To: Tomcat List
> >> Subject: request parameter question ...
> >>
> >>
> >> Hi ,
> >>
> >> In my servlet I have the following code:
> >>
> >> String str = request.getParameter("name");
> >>
> >> if(str.equals("xyz") == true)
> >> {
> >>str = "ChangedName";
> >>request.setParameter("name", str);   //
> >> <- how
> >> do i do this ??? There is no method as request.setParameter()
> >> }
> >>
> >> try
> >> {
> >>String path = "/SomeJSP.jsp"
> >>
> >> getServletConfig().getServletContext().getRequestDispatcher(pa
> >> th).forwar
> >> d(request, response);
> >> }
> >> catch(Exception ex)
> >> {
> >>ex.printStackTrace();
> >> }
> >>
> >> one way to do it would be to append the parameter and its
> >> changed value
> >> to the path:
> >> String path = "/SomeJSP.jsp?name=str";
> >>
> >> But is there some method like setParameter to do what I
> want to do ?
> >>
> >> Thanks.
> >>
> >>
> >>
> -
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail:
> [EMAIL PROTECTED]
> >>
> >>
> >
> >
> -
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]