Generated Java files using Jasper has incorrect names...
I used JASPER 2 which includes with TOMCAT (6.0.20), to pre compile some of my JSP files, but there is a problem with file names which are pre compiled by Jasper. If there is a underscore on JSP files then Jasper will generate Java files with incorrect names. e.g. compiled JSP file - get_BreadCrumbs.jsp pre compiled Java file - get_005fBreadCrumbs_jsp.java as you can see name has some unnecessary 005f tag on the name. How to prevent this, any idea -- _A_N_I_M_E_-_O_T_A_K_U_
Re: Help required for SMAP....
Thanks for the reply, I guessed that also, but i think there are some problems in this approach. If you look at JSP line from 3 to 13 you'll find this, 3. % 4. %@ page import=java.util.* % 5. %@ page import=java.text.* % 6. !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; 7. html 8. head 9. meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 10. titleInsert title here/title 11. /head 12. body 13. % on JAVA file, 55. out.write(\r\n\r\n\n!DOCTYPE html PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\ \http://www.w3.org/TR/html4/loose.dtd\;\nhtml\nhead\nmeta http-equiv=\Content-Type\ content=\text/html; charset=ISO-8859-1\\ntitleInsert title here/title\n/head\nbody\n); As you can see on the JAVA line the imports are not present which exist in JSP lines 4 and 5 You can find those imports in, JAVA file on the following lines. 6. import java.util.*; 7. import java.text.*; so the correct mapping should be 6,6:55,0 and 3,2:6,1 That's the issue, Is this a bug in TOMCAT SMAP feature ? I'm so confused btw is there a easier way to capture code line numbers other than using a .BAT file or creating a program for it
Compiling JSP with SMAP
I'm using apache-tomcat-6.0.20 with JASPER 2 I need to compile a web project (Eclipse WAR application) which is JSP to JAVA source files. I'm successfully generating JAVA files from JSP files (Used JASPER 2), but now i need to get mapping from JSP lines to JAVA lines. I tried using SMAP feature which available in JASPER 2, but i can't configure it correctly. There are two questions i need to ask, 1) Will generating SMAP files will help me to map JSP lines to generated JAVA lines? 2) How to do this? JASPER how to doc says - The servlet which implements Jasper is configured using init parameters in your global $CATALINA_BASE/conf/web.xml. I edited that web.xml with following code - (used dumpSmap suppressSmap) servlet servlet-namejsp/servlet-name servlet-classorg.apache.jasper.servlet.JspServlet/servlet-class init-param param-namesuppressSmap/param-name param-valuefalse/param-value /init-param init-param param-namedumpSmap/param-name param-valuetrue/param-value /init-param /servlet But no luck Any help! -- _A_N_I_M_E_-_O_T_A_K_U_
Re: Compiling JSP with SMAP
@Mercy, Thanks I managed to create SMAP files, using this code in my BUILD.XML - which compiles JSPs taskdef classname=org.apache.jasper.JspC name=jasper2 classpath refid=tomcat.classpath / /taskdef target name=jasper.jspc echo message=Starting JASPER/JSPC compiler... / jasper2 validateXml=false failonerror=false package=${module.name} smapSuppressed=false smapDumped=true compilertargetvm=1.6 compilersourcevm=1.6 classdebuginfo=true listErrors=true verbose=9 uriroot=${web.dir} webXmlFragment=${tool.work.dir}/generated_web.xml outputDir=${tool.web.scr.dir} / /target Now it is creating .SMAP files. Now a new problem arise, How to read a .SMAP file, I know its map from JSP to JAVA but how the numbers are associated, (can someone explain) is there an easier way to do this?
Help required for SMAP....
Can someone help me to understand SMAP feature (how the mapping is indicated in files) in TOMCAT? (a reference link or a book would be great) -- _A_N_I_M_E_-_O_T_A_K_U_
Re: Help required for SMAP....
Not URL mapping, i need to understand SMAP mapping, here's a SMAP file i created, (when compiling JSP to JAVA sources) SMAP time_jsp.java JSP *S JSP *F + 0 time.jsp mytest/time.jsp *L 3,11:55,0 14,3:57 16,3:60,0 18:61 19,2:62,0 *E this is JSP line to JAVA line mapping ??? but i found that they are indicated incorrectly... like line JSP line 3 to 11 should map to JAVA line 55 but its not indicating this correctly. JAVA line 55 only contains lines from 6 to 12 of original JSP. Is this a bug in TOMCAT or Problem with my compiling. time.jsp %@ page language=java contentType=text/html; charset=ISO-8859-1 pageEncoding=ISO-8859-1 % %@ page import=java.util.* % %@ page import=java.text.* % !DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN http://www.w3.org/TR/html4/loose.dtd; html head meta http-equiv=Content-Type content=text/html; charset=ISO-8859-1 titleInsert title here/title /head body % Date day = new Date(); String today = DateFormat.getDateInstance().format(day); % Today is: em%=today %/em /body /html time_jsp.java package sdasdasd_jsp.mytest; import javax.servlet.*; import javax.servlet.http.*; import javax.servlet.jsp.*; import java.util.*; import java.text.*; public final class time_jsp extends org.apache.jasper.runtime.HttpJspBase implements org.apache.jasper.runtime.JspSourceDependent { private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory(); private static java.util.List _jspx_dependants; private javax.el.ExpressionFactory _el_expressionfactory; private org.apache.AnnotationProcessor _jsp_annotationprocessor; public Object getDependants() { return _jspx_dependants; } public void _jspInit() { _el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory(); _jsp_annotationprocessor = (org.apache.AnnotationProcessor) getServletConfig().getServletContext().getAttribute(org.apache.AnnotationProcessor.class.getName()); } public void _jspDestroy() { } public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException { PageContext pageContext = null; HttpSession session = null; ServletContext application = null; ServletConfig config = null; JspWriter out = null; Object page = this; JspWriter _jspx_out = null; PageContext _jspx_page_context = null; try { response.setContentType(text/html; charset=ISO-8859-1); pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true); _jspx_page_context = pageContext; application = pageContext.getServletContext(); config = pageContext.getServletConfig(); session = pageContext.getSession(); out = pageContext.getOut(); _jspx_out = out; out.write(\r\n\r\n\n!DOCTYPE html PUBLIC \-//W3C//DTD HTML 4.01 Transitional//EN\ \http://www.w3.org/TR/html4/loose.dtd\;\nhtml\nhead\nmeta http-equiv=\Content-Type\ content=\text/html; charset=ISO-8859-1\\ntitleInsert title here/title\n/head\nbody\n); Date day = new Date(); String today = DateFormat.getDateInstance().format(day); out.write(\r\nToday is:\r\nem); out.print(today ); out.write(/em\n/body\n/html); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null out.getBufferSize() != 0) try { out.clearBuffer(); } catch (java.io.IOException e) {} if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } } As i know