How to use GET and Post methods in the same JSP form? URGENT PLEASE!!!

I have 2 programs,

*dealForm.jsp to accept a currency, convert it a

*dealLoad.jsp to store the details of the dealForm in my database.

In the form, before the dataload part, I convert the entered amount into required currency. The URL to retrieve this information is:

http://finance.yahoo.com/download/javasoft.beans?SYMBOLS=USDDEM=x&format=ab

I can write a program with the following code to get the information from the URL:

String urlString = "http://finance.yahoo.com/download/javasoft.beans?SYMBOLS=" +symbol + "&format=ab";try {URL url = new URL(urlString);URLConnection con = url.openConnection();InputStream is = con.getInputStream();InputStreamReader isr = new InputStreamReader(is);BufferedReader br = new BufferedReader(isr);String line = br.readLine();StringTokenizer tokenizer = new StringTokenizer(line,",");name = tokenizer.nextToken();name = name.substring(1, name.length()-2); // remove quotesprice = tokenizer.nextToken();price = price.substring(1, price.length()-2); // remove quotes } catch (IOException exception) {System.err.println("IOException: " + exception);

The code was fro an example I saw on the net. The following piece of JSP will retrieve the value.

<form action="dealForm.jsp"method="GET"> <p>Enter Symbol: <input size="20" name="symbol"><inputtype="submit" value="Submit"></p></form><%if (request.getParameter("symbol") != null) {%>

The Problem:

My actual form, before using the code to convert, is set up in a way that the dealForm.JSp has a 'POST' and calls another jsp to loaddata intothe database.

However, the above code uses "GET" method so that the dealForm.jsp's action tag calls dealForm.jsp itself.

Is it possible to combine these two? I am nowhere near making my code work, and can someone please help?

Thanks for your time!

[1942 byte] By [uma_var] at [2007-9-26 3:39:17]
# 1
did you tried <forward> or <include> or <%include%>
simmy1 at 2007-6-29 12:13:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks. But how do I include or forward?Can you help please?
uma_var at 2007-6-29 12:13:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

uma_var,

I think simmy1 was trying to ask you whether you are using forward or include.

I am sure there is simple answer/solution to your issue/problem. But you have to provide more context to you effort to get an answer. And what better way is there to do that than to post more code.

neville_sequeira at 2007-6-29 12:13:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

Here is a modified dealForm.jsp that merges the 2 steps - both symbol submission and Yahoo convert is done by it. Play with it and add your DB code to it:

<html>

<head><title>IPIB Database Selection</title></head>

<body bgcolor="#DFDFFF">

<H1><CENTER>IPIB Database Selection</CENTER></H1>

<font size=4>

<%@ page language="java" %>

<%@ page import="java.net.*,java.io.*,java.util.*" %>

<%

String symbol = request.getParameter("symbol");

if (symbol != null) {

String urlString = "http://finance.yahoo.com/download/javasoft.beans?SYMBOLS=" + symbol + "&format=ab";

try {

URL url = new URL(urlString);

URLConnection con = url.openConnection();

InputStream is = con.getInputStream();

InputStreamReader isr = new InputStreamReader(is);

BufferedReader br = new BufferedReader(isr);

String line = br.readLine();

StringTokenizer tokenizer = new StringTokenizer(line,",");

String name = tokenizer.nextToken();

name = name.substring(1, name.length()-2);

String price = tokenizer.nextToken();

price = price.substring(1, price.length()-2);

%>

<p>

Original line from yahoo <%= line %>

</p> <p>

Name: <%= name %>

</p> <p>

Price: <%= price %>

</p> <p>

Pub DB processing code from dealLoad.jsp here

</p>

<%

} catch (IOException exception) {

System.err.println("IOException: " + exception);

}

} else { %>

<form action="dealForm.jsp"method="GET">

<p>Enter Symbol: <input size="20" name="symbol">

<inputtype="submit" value="Submit">

</p></form>

<% } %>

</font>

</body>

</html>

yilin at 2007-6-29 12:13:47 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...