Jump to content


SAMPLE CODE - .jsp or servlet

  • This topic is locked This topic is locked
2 replies to this topic

#1 richy



  • Members
  • Pip
  • 2 posts

Posted 17 January 2004 - 10:09 PM

I'm a student trying to figure out how to incorporate IPN.
We're developing a web site for an actual small business and will be using PayPal. I'd like to update the database (mySQL)as soon as something is sold. I'm trying out the sample code but I'm not sure if i should be putting it on a .jsp page or converting it to a servlet. I'm using struts as well. Are there any experts out there that can help?

#2 TreeHugger



  • Members
  • PipPip
  • 10 posts

Posted 24 January 2004 - 10:11 AM

I'm just starting off with this IPN, trying to incorporate it with struts (like znaps...). In case you didn't figure it out, JSPs are actually servlets, or at least at run-time they get converted into servlets. So on that count, it doesn't matter where you put the IPN code.

However since you are using struts, I would recommend doing the following. If anyone knows better, please correct me.

Set up an action mapping for your chosen URL (e.g. www.mysite.com/testipn.do) like so:

<action path="/testipn"

This will tell the struts servlet to call your 'ProcessIPN' class (just made that class name up), in which you should put the IPN code. You are using struts v1.1 right?

The ProcessIPN class should extend org.apache.struts.Action and your execute method should contain the code.

In the if...else blocks at the end of the code, you need to write code to do what the comments tell you to do.

The execute() method should return Null, because after you have processed the IPN, there is nothing more to do, no displaying or HTTP response necessary.

Znaps, does this all make sense, what I'm saying?


I want to feel your sweet embrace
But don't take that paper bag off of your face

#3 znaps



  • Members
  • Pip
  • 4 posts

Posted 24 January 2004 - 01:16 PM

Yep that's it. To answer your question on whether to use a Servlet or jsp, Servlets (or Struts Action classes) are easier to write and maintain than jsp's, so do it as a Servlet.

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users