473,473 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

ServletRequest.getParameter question

Hi,

I'm using ServletRequest.getParameter(), but how do I tell the difference a
parameter in the query part of a URL and a posted parameter (e.g. an input
field of a form where method="post").

Is there anything like the PHP equivalent of $_GET[] and $_POST[] which can
differentiate between parameters in a URL and posted parameters.

Thanks very much.

PS. I'm using the J2EE 1.4 API

--
Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"

May 5 '06 #1
5 7049

"Steve" <ro**@127.0.0.1> wrote in message
news:C0816F20.5911%ro**@127.0.0.1...
Hi,

I'm using ServletRequest.getParameter(), but how do I tell the difference a parameter in the query part of a URL and a posted parameter (e.g. an input
field of a form where method="post").

Is there anything like the PHP equivalent of $_GET[] and $_POST[] which can differentiate between parameters in a URL and posted parameters.

Thanks very much.

PS. I'm using the J2EE 1.4 API

--
Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good is that?"

look at the doGet and doPost methods-
do either one and have it call the other one - passing the request and
response object
May 8 '06 #2
On 8/5/06 01:23, in article J8*******************@bignews4.bellsouth.net,
"Hal Rosser" <hm******@bellsouth.net> wrote:

"Steve" <ro**@127.0.0.1> wrote in message
news:C0816F20.5911%ro**@127.0.0.1...
Hi,

I'm using ServletRequest.getParameter(), but how do I tell the difference a
parameter in the query part of a URL and a posted parameter (e.g. an input
field of a form where method="post").

look at the doGet and doPost methods-
do either one and have it call the other one - passing the request and
response object


That's what I thought initially, but what if I POST the url
'/webapp/servlet?param=value'

There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
parameter?

--
Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"

May 8 '06 #3
Steve wrote:
On 8/5/06 01:23, in article J8*******************@bignews4.bellsouth.net,
"Hal Rosser" <hm******@bellsouth.net> wrote:

"Steve" <ro**@127.0.0.1> wrote in message
news:C0816F20.5911%ro**@127.0.0.1...
Hi,

I'm using ServletRequest.getParameter(), but how do I tell the difference a
parameter in the query part of a URL and a posted parameter (e.g. an input
field of a form where method="post").


look at the doGet and doPost methods-
do either one and have it call the other one - passing the request and
response object

That's what I thought initially, but what if I POST the url
'/webapp/servlet?param=value'

There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
parameter?


Sure you can - just do a request.getMethod()... if its GET then you know
it was on the command line, if its POST, then you know it was posted.
You can also double check by parsing the URL and making sure that
variable was not in it...
May 11 '06 #4

"Questman" <qu******@UBESUXthemajorbbs.com> wrote in message
news:5U******************@fe04.usenetserver.com...
Steve wrote:
On 8/5/06 01:23, in article J8*******************@bignews4.bellsouth.net,
"Hal Rosser" <hm******@bellsouth.net> wrote:

"Steve" <ro**@127.0.0.1> wrote in message
news:C0816F20.5911%ro**@127.0.0.1...

Hi,

I'm using ServletRequest.getParameter(), but how do I tell the
difference a
parameter in the query part of a URL and a posted parameter (e.g. an
input
field of a form where method="post").
look at the doGet and doPost methods-
do either one and have it call the other one - passing the request and
response object

That's what I thought initially, but what if I POST the url
'/webapp/servlet?param=value'

There is no way (AFAICT) to tell whether 'param' was in the URL or a
posted
parameter?


Sure you can - just do a request.getMethod()... if its GET then you know
it was on the command line, if its POST, then you know it was posted. You
can also double check by parsing the URL and making sure that variable was
not in it...


That last check is dangerous: What if it were located in both?

- Oliver

May 11 '06 #5
On 11/5/06 17:46, in article 5U******************@fe04.usenetserver.com,
"Questman" <qu******@UBESUXthemajorbbs.com> wrote:
That's what I thought initially, but what if I POST the url
'/webapp/servlet?param=value'

There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
parameter?

Sure you can - just do a request.getMethod()... if its GET then you know
it was on the command line, if its POST, then you know it was posted.


The first bit I agree with - if the request method is GET, then obviously
there can be no body to the request so all params must be from the URL.

But, as I said what if I POST the url '/webapp/servlet?param=value'
Take the following HTML form for example:
<form method="post" action="/webapp/servlet?param1=value1">
<input type="hidden" name="param2" value="value2"/>
</form>

So tell me - what methods are available to indicate param1 was from the URL
and param2 was not.

You can also double check by parsing the URL and making sure that
variable was not in it...


I'd rather not re-invent the wheel if I don't have to.
--
Regards,
Steve

"...which means he created the heaven and the earth... in the DARK! How good
is that?"

May 11 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Harry | last post by:
Hi there, I have a problem attempting to get a parameter with the request.getParameter method. The problem is that the method is cutting off the parameter at 30 characters. The setup is as such....
3
by: Stevey | last post by:
I have the following XML file... <?xml version="1.0"?> <animals> <animal> <name>Tiger</name> <questions> <question index="0">true</question> <question index="1">true</question> </questions>
3
by: Ekqvist Marko | last post by:
Hi, I have one Access database table including questions and answers. Now I need to give answer id automatically to questionID column. But I don't know how it is best (fastest) to do? table...
53
by: Jeff | last post by:
In the function below, can size ever be 0 (zero)? char *clc_strdup(const char * CLC_RESTRICT s) { size_t size; char *p; clc_assert_not_null(clc_strdup, s); size = strlen(s) + 1;
56
by: spibou | last post by:
In the statement "a *= expression" is expression assumed to be parenthesized ? For example if I write "a *= b+c" is this the same as "a = a * (b+c)" or "a = a * b+c" ?
2
by: Allan Ebdrup | last post by:
Hi, I'm trying to render a Matrix question in my ASP.Net 2.0 page, A matrix question is a question where you have several options that can all be rated according to several possible ratings (from...
5
by: Nirmala123 | last post by:
hai, I want to update the database table values using the getParameter(). int rs=statement.executeUpdate("update address set name='xxxx' where name=("+request.getParameter("oldname")+")"); ...
7
by: mimsc | last post by:
ok I canged my code around...no more javascript...the problem now is the 'weatherStae" parameter is passing 'null' in request.getParameter...any suggestions?? 1st jsp: <form name="form1"...
3
by: Zhang Weiwu | last post by:
Hello! I wrote this: ..required-question p:after { content: "*"; } Corresponding HTML: <div class="required-question"><p>Question Text</p><input /></div> <div...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.