Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

sending data to jsp  RSS feed

 
Leonardo Pjetri
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<%@page language="java" %>
<HTML>
<BODY>
Hello! Enter stuff and press Log in
<FORM METHOD="POST" ACTION="test.jsp">
<TABLE>
<TR><TD>User name: <INPUT TYPE="TEXT" NAME="username">
<TR><TD> Password: <INPUT TYPE="PASSWORD" NAME="password">
<TR><TH><INPUT TYPE="SUBMIT" VALUE="Log In">
</TABLE>
</FORM>
</HTML>
</BODY>
-----------------------------------------------the login page---
How would I modify the login page so that based on the input it post the data to different pages?
 
Scheepers de Bruin
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can change the forms action attribute using javascript.

Your submit button:

(remove the _ from on_click)
Your java script method:
 
Leonardo Pjetri
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

(remove the _ from on_click)

remove what with what?
 
Christopher Elkins
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the underscore from the word "on_click" in the code he wrote so that it becomes a single word.
 
Sripathi Krishnamurthy
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javascript is not the best way to check for conditions and redirect to different page. use MVC pattern. From a jsp, redirect to a servlet and check for conditions there. Do all the business logic in the servlet and then redirect back to a jsp based on the condition.
This way, you never have to modify the jsp again. Just keep changing the business logic in servlet whenever required.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!