Flash5
asked on
Http post without using form method.
I want to write a jsp page that will posting data to another page but i don't want to use <FORM METHOD="POST">
anyone have an idea on doing this?
thanks
anyone have an idea on doing this?
thanks
Is the another page a Web component (Servlet or JSP) in the same Web application?
ASKER
Sorry, i think i didn't clearly explain on my question.
Actually what i want is write my own post method in jsp without using <FORM METHOD="POST">
thanks
Actually what i want is write my own post method in jsp without using <FORM METHOD="POST">
thanks
or use
jsp:forward
jsp:forward
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
>> Is the another page a Web component (Servlet or JSP) in the same Web application?
Yes, it's Jsp too.
Yes, it's Jsp too.
oic then u write
<%!
// this defines the method at instance scope
void someMethod(someParams
{
// method goes here
}
>
then
<%
someMethod(with those parameters);
%>
<%!
// this defines the method at instance scope
void someMethod(someParams
{
// method goes here
}
>
then
<%
someMethod(with those parameters);
%>
ASKER
what i want to do is something like the below midlet:
HttpConnection conn = null;
String url = "http://www.mysite.com/login.jsp";
String agent = "Mozilla/4.0";
String rawData = "userid=joe&password=guess me";
String type = "application/x-www-form-ur lencoded";
String encodedData = encode( rawData ); // user-supplied
try {
conn = (HttpConnection) Connector.open( url );
conn.setRequestMethod( HttpConnection.POST );
conn.setRequestProperty( "User-Agent", agent );
conn.setRequestProperty( "Content-Type", type );
conn.setRequestProperty( "Content-Length",
encodedData.length() );
OutputStream os = conn.openOutputStream();
os.write( encodedData.getBytes() );
int rc = conn.getResponseCode();
... // process it
}
catch( IOException e ){
// handle the error here
}
HttpConnection conn = null;
String url = "http://www.mysite.com/login.jsp";
String agent = "Mozilla/4.0";
String rawData = "userid=joe&password=guess
String type = "application/x-www-form-ur
String encodedData = encode( rawData ); // user-supplied
try {
conn = (HttpConnection) Connector.open( url );
conn.setRequestMethod( HttpConnection.POST );
conn.setRequestProperty( "User-Agent", agent );
conn.setRequestProperty( "Content-Type", type );
conn.setRequestProperty( "Content-Length",
encodedData.length() );
OutputStream os = conn.openOutputStream();
os.write( encodedData.getBytes() );
int rc = conn.getResponseCode();
... // process it
}
catch( IOException e ){
// handle the error here
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi,
I am not very clear with your requirement, but what I understand from your question is that while submitting data from the browser, you do not want to use the html tab
<FORM METHOD="POST">
If my understanding is correct, then the this issue can be solved using JavaScript. What you can do is:
Put all the variables between the <FORM> </FORM> tag, and then write a javascript function like
function submitForm()
{
document.forms[0].action=" http://somedomain/submit.jsp";
document.forms[0].method=" post"; //document.forms[0].method ="get";
document.forms[0].submit() ;
}
Regards
Kartik
I am not very clear with your requirement, but what I understand from your question is that while submitting data from the browser, you do not want to use the html tab
<FORM METHOD="POST">
If my understanding is correct, then the this issue can be solved using JavaScript. What you can do is:
Put all the variables between the <FORM> </FORM> tag, and then write a javascript function like
function submitForm()
{
document.forms[0].action="
document.forms[0].method="
document.forms[0].submit()
}
Regards
Kartik
Hi just use
<form method =""> or <form method ="GET">
default get will fire if u put empty