This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I want to put my this servlet code in to jsp file. I'm already having this view to send mail like there is 3 textbox and 1 textarea. How do i do that. How do this controller's code will be called on clicking send button ?
[ December 12, 2006: Message edited by: Bear Bibeault ]
[BSouther: Added UBB Code Tags] [ December 13, 2006: Message edited by: Ben Souther ]
Maybe what you need to do is that, you want to call the servlet from the jsp on clicking a button of the jsp. Either you misunderstood what your boss said or you couldnt frame the question properly. In case you want to call the servlet from the jsp, change the form tag of your jsp to include the name of the servlet in the action attribute.
something like <form action='urlPatternOfServlet'>
Joined: Dec 12, 2006
No the view is ready in jsp..see the code
and the logic is in the Servlet sendMail.java
I'm being told to put the whole code of servlet in to this sendMail.jsp page.
and i guess in jsp on clicking submit some code should be called but don't know how to do that. can you suggest me the same...
[BSouther: Added UBB code tags] [ December 13, 2006: Message edited by: Ben Souther ]
You can't have the code that is supposed to react to the submission of a form in the same JSP that creates that form. The code in the JSP will execute on the server before the form is even sent to the user. Does that make sense?
Joined: Dec 12, 2006
ya, i told my boss what you said and now he told me to create another jsp page which will be called from sendMail.jsp.
In my opinion you can create a method in the new jsp and call that method in the same jsp. This method will be executed when this jsp is called. This way you can add your code in jsp. This is very bad practice to put java code in jsp but in your case you cant help it.