Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:Not a 100% on this but when you say document.forms[0].action = "/challan.do?method=calcBBSeries";
the web browser consider the link to be relative to the root of the domain name.
Hence if your link is something like, http://MyIP/Application/currentPage.do
then instead of hitting the link http://MyIP/Application/challan.do it hits http://MyIP/challan.do which might result in a Page not found.
Can you post the URL of the page that shows up in the browser when the page submits?
Alternately you can try removing the "/" from document.forms[0].action = "/challan.do?method=calcBBSeries"; and see if that helps!
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:Ok Let me take a point blank guess here. Are you displaying a JSP/HTML page directly?
What I mean is, is your URL of the page from where you are calling the document.forms[0].submit(); something like this --> http://localhost:8080/struts-blank/jsp/index.jsp or something like this http://localhost:8080/struts-blank/home.do
Posting the URL of the page from which you are making the call would help.
David Newton wrote:You should probably create the link using the Struts link tag, giving it the action you're submitting to.
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:What is the link of the page where this form is displayed.
I know that the link of the page that you want to redirect to is http://localhost:8080/struts-blank/challan.do?method=calcBBSeries? My question is what is the link of the page from which this action is happening?
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:
. You could tell what is happening by changing the form[0] method to a 'Get' and looking at the URL in the web browser when the onchange event happens.
.
Deeps Mistry wrote:
Hey,
I tried changing the form method to 'GET'. But i get an error saying:
The request sent by the client was syntactically incorrect (Request[/challan] does not contain handler parameter named method).
URL: http://localhost:8080/struts-blank/challan.do?nos_BL=12&BL=Select
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:
To pass the parameter method as part of the form you will need to use a hidden variable <input type='hidden' name='method'> in the form[0] & set its value to 'calcBBSeries' using JavaScript just before the step where you do document.forms[0].action = "/challan.do?method=calcBBSeries";
P.S : Is the code working when you give the full URL i.e. http://localhost:8080/struts-blank/challan.do?method=calcBBSeries and method is POST?
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:The code is correct except for the URL which should be,
document.forms[0].action = "challan.do"; i.e the URL without the '/'
In case it does not work, you could repeat the previous step to change the 'Post' to 'Get' and see the URL thats being called. The URL should be http://localhost:8080/struts-blank/challan.do?nos_BL=12&BL=Select&method=calcBBSeries. If its not post the URL that you are getting.
Pretty long thread eh:)
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:document.forms[0].method.value = calcBBSeries;
You need to put calcBBSeries in double quotes, it should read
document.forms[0].method.value = "calcBBSeries";
What you are currently doing is assigning document.forms[0].method the value of the variable calcBBSeries which incidentally is the name function ... and that's what you get in your url...Once you put "calcBBSeries" in double quotes you'll see all your problems solved! (Hopefully)
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:Ok let me explain.
document.forms[0].action = "challan.do?method=calcBBSeries statement is actually incorrect. A form submit action should not contain a parameter to be passed to the server, basically it should not contain a query string.
That's the reason when you use a Get the parameters are overwritten and you don't see it getting passed as part of the query string.
When you use a post the form in incorrectly getting submitted with query string parameters. A Post request should not have any query string parameters. This is the reason why it is working with a POST and not a GET. However this is still incorrect and may break on a different browser.
By setting a form variable like document.forms[0].method.value = "calcBBSeries"; what happens is when the form is submitted all the form variable are either submitted to the server as
1. Post - Inside the body of the request
2. Get - As a query string.
Hence the value of 'method' becomes available to the server in the form Bean.
As always the only ways we can know whats going wrong is if you post more code or give the Get and Post URL as in the previous posts...
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
David Newton wrote:I meant use the rewrite tag (I didn't mean the actual *link* tag) to generate the URL so you just specify the action.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |