You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by gennady <ge...@yahoo.com> on 2008/11/13 03:56:11 UTC

Something weird - PDF output crashes when using Google map

This code works fine:
<fo:table-cell display-align="center">
    <fo:table table-layout="fixed" border="1pt solid black">
		<fo:table-column/>
		<fo:table-body>
			<fo:table-row>
				<fo:table-cell text-align="center">
					<fo:block width="255px">
				 <% 
				  String marker =
"&amp;markers="+compProp.getLatitude()+","+compProp.getLongitude()+",mid"+color+mapOrder[counter-1];
			      String mapURL =
googleURL+"center="+compProp.getLatitude()+","+compProp.getLongitude()+"&amp;zoom=12&amp;size=245x185&amp;maptype=mobile"+marker+googleKey;
			      System.out.println("mapURL:::"+mapURL);
			      %>
					<fo:external-graphic src="<%= mapURL%>" content-width="245px"
content-height="185px" vertical-align="middle" padding-before="2px"
padding-after="2px" />														
					</fo:block>
				</fo:table-cell>
			</fo:table-row>
		</fo:table-body>
	</fo:table>										
</fo:table-cell>

But when I try to put some condition around it - put empty block, if no
latitude and longitude then it crashes:
<fo:table-cell display-align="center">	
<% if (compProp.getLatitude() != null) { %>					
<fo:table table-layout="fixed" border="1pt solid black">
												<fo:table-column/>
												<fo:table-body>
													<fo:table-row>
														<fo:table-cell text-align="center">
															<fo:block width="255px">
														 <% 
														  String marker =
"&amp;markers="+compProp.getLatitude()+","+compProp.getLongitude()+",mid"+color+mapOrder[counter-1];
													      String mapURL =
googleURL+"center="+compProp.getLatitude()+","+compProp.getLongitude()+"&amp;zoom=12&amp;size=245x185&amp;maptype=mobile"+marker+googleKey;
													      System.out.println("mapURL:::"+mapURL);
													      %>
															<fo:external-graphic src="<%= mapURL%>" content-width="245px"
content-height="185px" vertical-align="middle" padding-before="2px"
padding-after="2px" />														
															</fo:block>
														</fo:table-cell>
													</fo:table-row>
												</fo:table-body>
											</fo:table>	
											<% } else { %>	
												<fo:block></fo:block>
											<% } %>							
	</fo:table-cell>	

This is a part of error message:
21:52:07,378 ERROR [[jsp]] Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP

Generated servlet error:
The code of method _jspService(javax.servlet.http.HttpServletRequest,
javax.serv
let.http.HttpServletResponse) is exceeding the 65535 bytes limit


        at
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErro
rHandler.java:84)
        at
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher
.java:328)
        at
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java
:397)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:288)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:267)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:255)

Why is that?

Thank you,
-Gennady	
-- 
View this message in context: http://www.nabble.com/Something-weird---PDF-output-crashes-when-using-Google-map-tp20473950p20473950.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: invalid flag after regular expression

Posted by Sheldon Glickler <sh...@thevillages.net>.
Andreas Delmelle wrote:
> On 13 Nov 2008, at 20:43, Sheldon Glickler wrote:
> 
> Hi
> 
>> <snip />
>> Now I am left with wondering why the exec command didn't create the 
>> pdf -- but that is a different problem.
> 
> This needs some digging in the server logs, if I guess correctly...
> (if there is a server log somewhere, where the output from the exec() 
> command is dumped into?)

I solved it.  I added " > /dev/null" to the command.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: invalid flag after regular expression

Posted by Andreas Delmelle <an...@telenet.be>.
On 13 Nov 2008, at 20:43, Sheldon Glickler wrote:

Hi

> <snip />
> Now I am left with wondering why the exec command didn't create the  
> pdf -- but that is a different problem.

This needs some digging in the server logs, if I guess correctly...
(if there is a server log somewhere, where the output from the exec()  
command is dumped into?)


HTH!

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: invalid flag after regular expression

Posted by Sheldon Glickler <sh...@thevillages.net>.
Andreas Delmelle wrote:
> On 13 Nov 2008, at 19:38, Sheldon Glickler wrote:
> 
> Hi
> 
> <snip />
>> I use php code to generate the xml file.  This php is invoked via an 
>> AJAX call.  After the xml file is generated I use the php command
>>
>> exec(the_command_string_for_running_the_php);
> 
> How is the setup precisely? Since mixing client- and server-side 
> scripting is always a bit tricky, I just want to make sure I understand 
> correctly
> 
> If all is well, I'm guessing it looks a little like:
> 1° launch asynchronous request and return (client-side, Javascript)
> 2° generate the XML and send a response, indicating that it's ready to 
> be converted (server-side, PHP)
> 3° handle the response, by sending a second request, and return 
> (client-side, Javascript)
> 4° handle the second request, and send a response when complete 
> (server-side, PHP; your 'exec();' statement)
> 5° handle the new response, which could be something like setting the 
> 'src' attribute of an IFRAME to the location where the PDF was generated 
> (client-side, Javascript)

Not nearly that complicated.  There is only one AJAX call.

The browser is displaying a particular page (which was obtained via the 
AJAX route and filling in the template).  On that page are various 
fields, one of which is a button to create the pdf.  Clicking that 
button invokes a javascript that picks a few values off the page and 
does the AJAX call.  The php script invoked does the following:

1 - gather data from the database
2 - build the xml file, writing it in a particular folder
3 - invokes an exec command for the fop to build the pdf

It then returns, changing an innerHTML of a tag to indicate that the pdf 
file is in place -- but NOT do display the pdf.

All the work is done server side.  The exec call is synchronous with, 
and immediately after, the successful writing of the xml file.

> 
> Where step 3° (5° resp.) corresponds to the AJAX onreadystatechange() 
> handler attached to the request sent in step 1° (3° resp.).
> 
>> When I do that, I get the error message "invalid flag after regular 
>> expression".  I posted to the php and javascript newsgroups, but they 
>> said that it was probably from the fop.
> 
> Well, if you'll allow me to bounce back:
> The error has nothing to do with FOP. It is an error raised by the 
> browser, pointing to invalid Javascript embedded in HTML. In the 
> nastiest case, it could simply be a silly missing quote somewhere in the 
> generated HTML... :/

I looked at this last paragraph of yours and starting thinking.  I was 
seeing that message in Firebug.  I also saw there what the entire 
command string was.  That was from a print statement.  When I removed 
that print statement, the error message disappeared.

Now I am left with wondering why the exec command didn't create the pdf 
-- but that is a different problem.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: invalid flag after regular expression

Posted by Andreas Delmelle <an...@telenet.be>.
On 13 Nov 2008, at 19:38, Sheldon Glickler wrote:

Hi

<snip />
> I use php code to generate the xml file.  This php is invoked via an  
> AJAX call.  After the xml file is generated I use the php command
>
> exec(the_command_string_for_running_the_php);

How is the setup precisely? Since mixing client- and server-side  
scripting is always a bit tricky, I just want to make sure I  
understand correctly

If all is well, I'm guessing it looks a little like:
1° launch asynchronous request and return (client-side, Javascript)
2° generate the XML and send a response, indicating that it's ready to  
be converted (server-side, PHP)
3° handle the response, by sending a second request, and return  
(client-side, Javascript)
4° handle the second request, and send a response when complete  
(server-side, PHP; your 'exec();' statement)
5° handle the new response, which could be something like setting the  
'src' attribute of an IFRAME to the location where the PDF was  
generated (client-side, Javascript)

Where step 3° (5° resp.) corresponds to the AJAX onreadystatechange()  
handler attached to the request sent in step 1° (3° resp.).

> When I do that, I get the error message "invalid flag after regular  
> expression".  I posted to the php and javascript newsgroups, but  
> they said that it was probably from the fop.

Well, if you'll allow me to bounce back:
The error has nothing to do with FOP. It is an error raised by the  
browser, pointing to invalid Javascript embedded in HTML. In the  
nastiest case, it could simply be a silly missing quote somewhere in  
the generated HTML... :/



HTH!

Cheers

Andreas
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


invalid flag after regular expression

Posted by Sheldon Glickler <sh...@thevillages.net>.
First of all, thank you to all who have helped me get this far.

I have an xsl and can generate the appropriate xml from the data in the 
database.  When I run the fop command manually, it generates a very nice 
looking pdf with no errors (other than a font message).

I use php code to generate the xml file.  This php is invoked via an 
AJAX call.  After the xml file is generated I use the php command

exec(the_command_string_for_running_the_php);

When I do that, I get the error message "invalid flag after regular 
expression".  I posted to the php and javascript newsgroups, but they 
said that it was probably from the fop.  I also googled for the message 
with very little luck and I search for the message in all my code 
without finding it.

Does anyone have a suggestion?  As a last resort I will set up a cron 
job to run it if the xml file is there and the pdf is not there. 
However, I would much rather this happen synchronously.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Something weird - PDF output crashes when using Google map

Posted by Andreas Delmelle <an...@telenet.be>.
On 13 Nov 2008, at 16:49, gennady wrote:

Hi

>
> Danke Andreas!
> I changed from <%@ include> to <jsp:include> and it works now. I'm  
> not sure
> why extra condition causes that crash, but that change fixed the  
> inclusion.

That's because <%@include ...> is actually like a macro, which is  
expanded at compile-time. The included JSP is included /before/ the  
base JSP is converted to a Java class. The <jsp:include ...> tag OTOH,  
is expanded at run-time. (i.e. in the latter case, the included JSPs  
will not influence the size of the including Java class; in the first  
case, the resulting Java class will be bigger).


HTH!

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Something weird - PDF output crashes when using Google map

Posted by gennady <ge...@yahoo.com>.
Danke Andreas!
I changed from <%@ include> to <jsp:include> and it works now. I'm not sure
why extra condition causes that crash, but that change fixed the inclusion.

-Gennady


Andreas Delmelle-2 wrote:
> 
> 
> On 13 Nov 2008, at 03:56, gennady wrote:
> 
> Hi
> 
>> This code works fine:
> <snip />
>>
>> But when I try to put some condition around it - put empty block, if  
>> no
>> latitude and longitude then it crashes:
> <snip />
>>
>> This is a part of error message:
>> 21:52:07,378 ERROR [[jsp]] Servlet.service() for servlet jsp threw  
>> exception
>> org.apache.jasper.JasperException: Unable to compile class for JSP
>>
>> Generated servlet error:
>> The code of method _jspService(javax.servlet.http.HttpServletRequest,
>> javax.serv
>> let.http.HttpServletResponse) is exceeding the 65535 bytes limit
> 
> Nothing weird. You just hit an upper limit. Due to the added  
> condition, your JSP file when translated, now generates a service  
> method that is longer than 64K bytes.
> Consider splitting it up into multiple files, and use <jsp:include>,  
> or at least try to introduce a little more structure in the code and  
> you should be fine.
> 
> 
> HTH!
> 
> Cheers
> 
> Andreas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Something-weird---PDF-output-crashes-when-using-Google-map-tp20473950p20481668.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Something weird - PDF output crashes when using Google map

Posted by Andreas Delmelle <an...@telenet.be>.
On 13 Nov 2008, at 03:56, gennady wrote:

Hi

> This code works fine:
<snip />
>
> But when I try to put some condition around it - put empty block, if  
> no
> latitude and longitude then it crashes:
<snip />
>
> This is a part of error message:
> 21:52:07,378 ERROR [[jsp]] Servlet.service() for servlet jsp threw  
> exception
> org.apache.jasper.JasperException: Unable to compile class for JSP
>
> Generated servlet error:
> The code of method _jspService(javax.servlet.http.HttpServletRequest,
> javax.serv
> let.http.HttpServletResponse) is exceeding the 65535 bytes limit

Nothing weird. You just hit an upper limit. Due to the added  
condition, your JSP file when translated, now generates a service  
method that is longer than 64K bytes.
Consider splitting it up into multiple files, and use <jsp:include>,  
or at least try to introduce a little more structure in the code and  
you should be fine.


HTH!

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org