Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in calling a method into jsp  RSS feed

 
veebhu singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Help!!!
While establishing the connection with MS Access using Servlets and JSPs in Tomcat 6.0, I encountered following problem:-

1. I am taking values from a jsp form(index.jsp).
2. Then, I received the values in a servlet(output.java) using getParameter.
3. Then, using requestDispatcher, I am forwarding values to another jsp (screen.jsp) to print it in a desired way.


PART OF SERVLET "output.java".......................




All these things go properly.
Problem arises when I am trying to save those values in a database in MS Access.

4. Class(mail.java) which I have constructed to insert those values in database is receiving those values from same servlet (output.java)




I am calling this above insertdata() method in screen.jsp as following:-



While running it Tomcat, it gives error that mail cannot be resolved.
It is for sure that problem lies in importing the mail.java class in screen.jsp.

DIRECTORY STRUCTURE:-
Both classes output.java and mail.java lie in mywebapp's default class directory.
Both JSPs index.jsp and screen .jsp lie in mywebapp parallel to WEB-INF .

I am not getting how to run that insertdata() method through screen.jsp

Please Help me.
Thanks in advance.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't have any Java code in a JSP. Why is it there?

 
veebhu singh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:You shouldn't have any Java code in a JSP. Why is it there?





Sorry,I didn't get.
Sir, JSPs are meant to put java code using scriplets.I mean Whatever java code is there, it is within the <% %>. Is it wrong?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65824
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's wrong.

Putting scriptlets and Java code into a JSP has been discredited since the introduction of JSP 2.0 over 8 years ago.

It's well past time to update your JSP knowledge. Java code should be placed into controllers and beans, and your web application should be properly constructed using modern principles.

Perhaps this article might be a good place to start.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!