• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to manage same servlet for different jsps

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have a login page where user information is collected passed to the servlet where it is connected to DAO class where it validates the email received with the database.If emails are different it will provide new userid for that user sends it to register.jsp.Now the user enters the password and all the in formation should be stored in the database.How to connect to the servlet now? Is the same servlet we have to use( if so how and what method we have to use?)If different servlet how it is?I am using MVC architecture.
Please suggest me.
KH
 
Ranch Hand
Posts: 153
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavitha ,


You can use different Servlet or same servlet .
But as if you find some information about MVC it is said that Servlet should be made as controller and how it is made is by using only single servlet and giving wildcard mapping for servlet .
One of the topic may help you is https://coderanch.com/t/359118/Servlets/java/Wildcard-servlet-mappings-web-xml OR you can also search for the wildcard mapping for servlet .


- Chetan

Guys correct me if anything doesn't seems right.
 
Kavitha hebbar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chetan Dorle wrote:Hi Kavitha ,


You can use different Servlet or same servlet .
But as if you find some information about MVC it is said that Servlet should be made as controller and how it is made is by using only single servlet and giving wildcard mapping for servlet .
One of the topic may help you is https://coderanch.com/t/359118/Servlets/java/Wildcard-servlet-mappings-web-xml OR you can also search for the wildcard mapping for servlet .


- Chetan

Guys correct me if anything doesn't seems right.



Hi,

thanks for the reply.But i did not get how to retrieve the values from second jsp form in the same servlet.Also i got 405 error saying get method is not supported by the url when i gave /* in servlet mapping.
Thank u.
Kavitha Gh
 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavitha ,

Can you mention your complete Servlet mapping in web xml and <form> action you are calling from page ?


- Chetan
 
Kavitha hebbar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm attaching the file form.jsp where i get info initially and goes to servlet for validation.Then comes web.xml where i map.Now i send some uid to register.jsp.in this jsp, user is allowed to enter password and here i want this to go to same servlet and thereby the data is stored into database.Is it possible and correct?How can it be achieved?
Thank u.
Kavitha hebbar
form.jsp

After this using a servlet which overrides dopost method and there i retrieve values from form.jsp thru request.getparameter.I don't know how to pass from register.jsp to same servlet and how to retrieve values.
Please help me.
 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Tomcat Server Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kavitha,

You can give same name in the action which you have given in form.jsp .
The problem is how you will decide that how decide from where servlet is called , for this you can add one hidden field in the form having value "REGISTER_FORM" and you can then easily distinguish.

I have modified register JSP





register.jsp



In the servlet you can write like


if("REGISTER_FORM".equalIgnoreCase(request.getParameter("FORM_SUBMITTED")))
{

// Do that database insertion code
//block for register.jsp

}
else
{

//This is for form.jsp
}


- Chetan
 
Kavitha hebbar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.
Kavitha hebbar
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic