How can I import JTSL libraries in Confluence ?
Asked by Nelson Jimenez Manio:


Answers:
author: Nelson Jimenez Manio
body: Have use the plugin before ? Can't seem to configure using the Dynamic parameter as I need to request start and end date from user in the form of Month and year.

comments: author: Alex Medved _ConfiForms_
body: Have not used the plugin in real-world scenarios. So, developing a custom plugin for Confluence is a better option, than messing around with custom JSPs.<https://developer.atlassian.com/docs/getting-started/set-up-the-atlassian-plugin-sdk-and-build-a-project/create-a-helloworld-plugin-project><https://developer.atlassian.com/display/CONFDEV/Creating+a+New+Confluence+Macro>We can take it offline, contact us via the contact form on <http://www.confiforms.com/cfweb/> and I can try to help you to start with your custom plugin development


author: Nelson Jimenez Manio
body: Actually, my goal is to use the Confluence's instance web server functionality to call a user defines JSP which will be located <http://Confluence> Apps/admin/xxxxxx.jsp to access a table and to display the content on screen:

I have created the following:

\<html\> \<head\>\<title\>Space/Page Statistics\</title\>\</head\> \<body\> \<%@ page import="java.util.\*" %\> \<%@ page import="javax.sql.\*;" %\> \<%

java.sql.Connection con; java.sql.Statement s; java.sql.ResultSet rs; java.sql.PreparedStatement pst;

con=null; s=null; pst=null; rs=null;

// Remember to change the next line with your own environment String url= "jdbc:<mysql://mysql>-wiki-1.test.internal/wiki"; String id= ""; String pass = "";

try{

Class.forName("com.mysql.jdbc.Driver"); con = java.sql.DriverManager.getConnection(url, id, pass);

}catch(ClassNotFoundException cnfex){ cnfex.printStackTrace();

} String sql = "SELECT PageAccessedURL, COUNT(PageAccessedURL) \`HitCount\` FROM confluence_access_logs WHERE EntryDate \>= '2015-01-06 18:46:50' AND EntryDate \<= '2015-01-07 00:20:21' GROUP BY PageAccessedURL ORDER BY HitCount DESC limit 10 ";

try{ s = con.createStatement(); rs = s.executeQuery(sql); %\> \<table border="1"\> \<tr\> \<th\>Space/Page Name\</th\> \<th\>Hit Count \</th\> \</tr\> \<% while( rs.next() ){ %\>\<tr\> \<td\>\<%= rs.getString("PageAccessedURL") %\>\</td\> \<td\>\<b\>\<%= rs.getString("HitCount") %\>\</b\>\</td\> \</tr\> \<% } %\>

\<%

}

catch(Exception e){e.printStackTrace();} finally{ if(rs!=null) rs.close(); if(s!=null) s.close(); if(con!=null) con.close(); }

%\> \</table\> \</body\> \</html\>

comments: author: Alex Medved _ConfiForms_
body: I believe that developing this as a plugin would make more sense (as additionally to custom functionality you can develop yourself, there is a huge stack of Atlassian libraries you can access/use, and it is all initialized and ready to use, knows your user, context, etc).And for this particular case there are plugins already available: PocketQueryDeveloping some custom JSPs that just run within the Java Container... especially, the code you have pasted: no db connection pool, driver is initialized on request... not very efficient


author: Alex Medved _ConfiForms_
body: Why would you need it? You cannot use JSPs as your templates in Confluence.

You can have a servlet defined, yes, but the templating engine is Velocity, not JSP.