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
Flash5Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

vikraman_bCommented:
>>I want to write a jsp page that will posting data to another page but i don't want to use <FORM METHOD="POST">

Hi just use
<form method =""> or <form method ="GET">
default get will fire if u put empty
0
petmagdyCommented:
Is the another page a Web component (Servlet or JSP) in the same Web application?
0
Flash5Author Commented:
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
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

vikraman_bCommented:
or use
jsp:forward
0
vikraman_bCommented:
JSP Syntax
<jsp:forward page={"relativeURL" | "<%= expression %>"} />
or
<jsp:forward page={"relativeURL" | "<%= expression %>"} > 
<jsp:param name="parameterName"
          value="{parameterValue | <%= expression %>}" />+
</jsp:forward>
Examples
<jsp:forward page="/servlet/login" />
<jsp:forward page="/servlet/login">
<jsp:param name="username" value="jsmith" />
</jsp:forward>
0
Flash5Author Commented:
>> Is the another page a Web component (Servlet or JSP) in the same Web application?

Yes, it's Jsp too.
0
vikraman_bCommented:
oic then u write

<%!
// this defines the method at instance scope

void someMethod(someParams
{
        // method goes here
}
>

then

<%
        someMethod(with those parameters);
%>

0
Flash5Author Commented:
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=guessme";
String type = "application/x-www-form-urlencoded";

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
}
0
petmagdyCommented:
then on our source JSP u can do:

request.setAttribute("param", "value");
 getServletConfig().getServletContext().getRequestDispatcher("TargetJsp.jsp").forward(request, response);

on the target jsp:
value = request.getAttribute("param")
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KartikShahCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.