• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to auto submit JSP

 
munch Chaudhary
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two login jsps in my application. if user enters his details on first JSP, second jsp is not displayed to user and should automatically get submitted with the details that user entered on first JSP.

To achieve above what I am doing is:

Storing the user id and password in session. On Second JSP I am checking if any user id and password not stored in Session then render second login JSp.
But if userid and password are already present in session then this second login JSP should automatically get submitted.

Where I am stuck is how to achieve this automatic behavior.
Can we directly call a JavaScript function from a jsp ( I mean without attaching it to any event, i.e. as we do call our java functions?)

Any ideas will be helpful.
 
damodar kumar
Ranch Hand
Posts: 77
Android Chrome MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

yes you can clla java script

first in jsp check all fields are entered or not if so that call the action to move to another jsp.


Regards,

Dam
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "mmm patni"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. Basically, it must consist of a first name, a space, and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do right here.

As to the question, if the second JSP may require no user interaction, why does it even get rendered? This is the kind of thing the controller in an MVC architecture should decide, which can then perform any DB interactions necessary, and finally dispatch to whatever page the user should actually see.

Keeping this kind of logic in a JSP (or worse, JavaScript) would be an ugly design that's also unnecessarily hard to understand and maintain.
 
munch Chaudhary
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey Thanks for directing to naming policies...

this application of mine will be a part of JAAS implmentation on top of MVC applications. This itself does not follow any MVC architecture. I have to follow the existing design, please help with a solution to achive that.



[ UD: removed CODE tags ]
[ September 09, 2008: Message edited by: Ulf Dittmer ]
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does an "MVC application" not use an MVC architecture?

But anyway, the important thing is not MVC, the important thing is not to use JSPs for making decisions about flow of control, and not rendering a JSP that possibly shouldn't be shown.
 
anuj patel
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Hi

you can also submit the page on form load using the javascript
write this code in your second jsp

function submitJSP()
{
document.FrmUser.Submit();
}

Thanks & Regards,
Anuj Patel
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic