From: Husain on
Hello.

I have a form in which after submission displays several messages
depending on what the user has inputted. The form goes to a
AddCompanyHandle.jsp page where the input is verified and added into
the database.


I have a different jsp page called Message.jsp which displays the
appropriate message in a separate frame. Thus, an example of which
message is to be displayed is shown below. (This code will be in
AddCompanyHandle.jsp)

<jsp:forward page="Message.jsp">
<jsp:param name="Msg" value="Please enter valid tel/fax number. Only
digits please" />
</jsp:forward>

Thus Message.jsp will run getParameter and display the message in a
separate frame called MessageFrame. (In order to do that, I already
set the target of the form to MessageFrame).

However, if the form is correctly filled and completed, I would like
to redirect the page to the main page. I used
response.sendRedirect("Main.jsp"). However due to the target which I
already set in the form, this page loads in the MessageFrame which is
not what I want. I want it to load in the MainFrame if and only if the
form is correctly filled.

So, my question is, is there a way where I can change the target of
the form after it is submitted and sens to a jsp page to be handled?

Thank you for your kind help.
From: Bart Van der Donck on
Husain wrote:

> I have a form in which after submission displays several messages
> depending on what the user has inputted. The form goes to a
> AddCompanyHandle.jsp page where the input is verified and added into
> the database.
>
> I have a different jsp page called Message.jsp which displays the
> appropriate message in a separate frame. Thus, an example of which
> message is to be displayed is shown below. (This code will be in
> AddCompanyHandle.jsp)

Why make things so complex ?

> <jsp:forward page="Message.jsp">
> <jsp:param name="Msg" value="Please enter valid tel/fax number. Only
> digits please" />
> </jsp:forward>
>
> Thus Message.jsp will run getParameter and display the message in a
> separate frame called MessageFrame. (In order to do that, I already
> set the target of the form to MessageFrame).
>
> However, if the form is correctly filled and completed, I would like
> to redirect the page to the main page. I used
> response.sendRedirect("Main.jsp"). However due to the target which I
> already set in the form, this page loads in the MessageFrame which is
> not what I want. I want it to load in the MainFrame if and only if the
> form is correctly filled.
>
> So, my question is, is there a way where I can change the target of
> the form after it is submitted and sens to a jsp page to be handled?

<form target="one" name="myform" onSubmit="

alert('Target is now: ' + document.myform.target);
document.myform.target = 'two';
alert('Target is now: ' + document.myform.target);

">
<input name="field">
<input type="submit">
</form>

Hope this helps,

--
Bart