YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

SAMPLE CODE - .jsp or servlet Options
richy
#1 Posted : Sunday, January 18, 2004 3:09:31 AM
Rank: Starting Member

Groups: Registered

Joined: 1/18/2004
Posts: 2
Location: ,
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?
Sponsor  
 
TreeHugger
#2 Posted : Saturday, January 24, 2004 3:11:28 PM
Rank: Starting Member

Groups: Registered

Joined: 1/24/2004
Posts: 10
Location: ,
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"
type="com.mysite.payments.ProcessIPN">
</action>

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?



Adam

I want to feel your sweet embrace
But don't take that paper bag off of your face
znaps
#3 Posted : Saturday, January 24, 2004 6:16:42 PM
Rank: Starting Member

Groups: Registered

Joined: 1/21/2004
Posts: 4
Location: ,
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.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAFVision Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF | YAF © 2003-2009, Yet Another Forum.NET
This page was generated in 0.275 seconds.