• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

sending data to jsp

 
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?
 
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?
 
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.
 
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.
 
There are 10 kinds of people in this world. Those that understand binary get this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic