Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Form Error Messages/Redirecting  RSS feed

 
Scotty McCoy
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I graduated from college with a degree in Web Development, and for some reason I am drawing a complete blank with what I'm trying to do. I don't know why I am having this issue, but I have been trying to work on it for the past few days now and I tried everything I can. I DON'T want to use a Servlet, whether it'll be easier or not, I just want complete JSP pages. I will have the code snippets below for all the pages I have that deals with where I am having issues. And this project is NOT for school or work or anything like that. But I have a page called register.jsp where a user can fill out a form to sign up for an account. I have another page called newmember.jsp which will do the backend code for the registration form. If a user signing up for an account on register.jsp has a username that is already in use, it'll tell them that in an error message due to response.sendRedirect. If a member signs up for an account and is under the age of 13 years old, they'll be given an error message due to response.sendRedirect. I'm also going to add in the same thing with an email already in use, but don't have that in now because I want to get these two working first. If a combination of the above listed errors are entered in the form and submitted, it'll list the error messages associated with that response.sendRedirect. Currently, it is working, however, not correctly. If a user has a taken username and is above 13 years old, both messages display. And if the username is available, but the member is under 13 years old, both messages display as well. I don't know why I can't figure this out and I did have something similar in college years ago but can't remember what it was I did and I don't have the flash drive I had for class anymore. I know Servlets may be the best way to go, but I really just want this to be done using JSP, just how I am preferring this to be. Any help would be greatly appreciated. Below are the code snippets.

register.jsp



newmember.jsp

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

Scotty McCoy wrote:I DON'T want to use a Servlet, whether it'll be easier or not, I just want complete JSP pages.

Bad, bad, bad, bad, and did I say bad idea. Why the insistence on using the wrong tools for the job?

JSPs are meant for the view portion of the web app. Servlets should be used as the controllers. Using JSPs for anything other than view is like, well:



I also see that you are using obsolete and outdated Java scriptlets in your pages. JSP 2 threw those out with the bathwater in 2002. Twelve years ago. You should be using the JSTL and EL in any JSP page written after 2002.

I'm assuming that you're not a newcomer to JSP, but I'd recommend reading this article anyways. But certainly read this article to understand how to properly construct a modern Java web app.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Your text will be easier to read by adding paragraphs. But I see you used code tags for your code -- good show!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!