tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davies, Joshua" <>
Subject RE: help in using a custom API
Date Tue, 25 Oct 2005 15:59:09 GMT
I'd avoid calling a third-party API from a JSP at all.  Instead, I'd
recommend using an MVC-style approach
like this:

public class ApiCallingServlet extends HttpServlet
	public void doGet( HttpServletRequest req, HttpServletResponse
resp )
		throws ServletException, IOException
			ApiResults results = req.getParameter(
"apiParam1" ),
req.getParameter( "apiParam2" ) );
			req.setAttribute( "meaningfulParameter1",
results.getMeaningfulParameter1( ) );
req.setAttribute( "meaningfulParameter2",
results.getMeaningfulParameter2( ) );

			ServletContext sc = getServletContext( );
			RequestDispatcher rd = sc.getRequestDispatcher(
"/jsp/api/ApiUser.jsp" );
			rd.forward( req, res );
		catch ( ApiGeneratedException e )
			throw new ServletException( e );

<p>The API gave meaningful result 1 of <%= request.getAttribute(
"meaningfulParameter1" ) %></p>
<p>The API gave meaningful result 2 of <%= request.getAttribute(
"meaningfulParameter2" ) %></p>

This way the example code can be pretty much copied directly into the
servlet's doGet or doPost method and modified from there.

-----Original Message-----
From: Jayel Villamin [] 
Sent: Monday, October 24, 2005 11:15 PM
Subject: help in using a custom API

Hi. We have bought an IT customer management system to management the 
helpdesk. It came with a JAVA API.

Here are is thin POS guide and some examples. The problem with the 
examples is that is uses plain Java (Java run from the commandline). 
But I need to use it from within a browser. Since my Java is at a 
beginner's level, I have been reading some online books were my work 
has accessed to (like O'rielly's JavaServer Pages, 3rd Edition). I 
have put the API jar file in /shared/lib but I cannot find a way on 
how to access it from a jsp page.

If anyone can point me to the right direction on how to use this API 
from within a JSP. I would really appreciate it.

Thank you.

Jayel Villamin, Web Programmer, Information Technology Services Division
+ Deakin University Geelong Victoria 3217 Australia.
( 03 5227 8688 International: +61 3 5227 8688
( 03 5227 8866 International: +61 3 5227 8866
Deakin University CRICOS Provider Code 00113B

Important Notice: The contents of this email transmission, including 
any attachments, are intended solely for the named addressee and are 
confidential; any unauthorized use, reproduction or storage of the 
contents and any attachments is expressly prohibited. If you have 
received this transmission in error, please delete it and any 
attachments from your system immediately and advise the sender by 
return email or telephone. Deakin University does not warrant that 
this email and any attachments are error or virus free.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message