<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MentorMate Company Blog&#187; Dimitar Dobrev | MentorMate Company Blog</title>
	<atom:link href="http://mentormate.com/blog/author/mitko/feed/" rel="self" type="application/rss+xml" />
	<link>http://mentormate.com/blog</link>
	<description></description>
	<lastBuildDate>Thu, 12 Aug 2010 14:59:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Optimized paging query implementation for Microsoft SQL Server 2005</title>
		<link>http://mentormate.com/blog/optimized-paging-queries-microsoft-sql-server-2005/</link>
		<comments>http://mentormate.com/blog/optimized-paging-queries-microsoft-sql-server-2005/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 15:03:38 +0000</pubDate>
		<dc:creator>Dimitar Dobrev</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[microsoft sql server 2005]]></category>
		<category><![CDATA[optimization]]></category>

		<guid isPermaLink="false">http://mentormate.com/blog/?p=45</guid>
		<description><![CDATA[Paging queries or paging records is an often-used approach in web applications. It displays subsets of data records as a page, allowing the user to navigate more easily through all pages. The straightforward implementation of a paging query running over large data sets in a stored procedure in MS SQL 2005 can cause increased server load when large numbers of paging queries are executed simultaneously.]]></description>
			<content:encoded><![CDATA[<p>We did performance tests on several methods of paging implementation and found the fastest one:</p>
<pre class="brush: plain;">DECLARE @PageNumber INT
DECLARE @PageSize INT
SET @PageNumber = 2
SET @PageSize = 10
SELECT TOP (@PageSize) * FROM
(
SELECT
ROW_NUMBER() OVER (ORDER BY FieldA) As RowID,
FieldB,FieldC,
TotalRows=COUNT(*) OVER()
FROM TheTable
) TmpTable
WHERE TmpTable.RowID &gt; ((@PageNumber-1)*@PageSize)</pre>
<p>One significant advantage of this implementation approach is that there is no need for a second query that returns the total count of the paged data. The total record count is returned as a column in the result set. This minimizes the number of queries that are needed to return a paged result set. If not needed, the “TotalRows” column can be removed from the query.</p>
]]></content:encoded>
			<wfw:commentRss>http://mentormate.com/blog/optimized-paging-queries-microsoft-sql-server-2005/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>&#8220;java.lang.OutOfMemoryError: Java heap space&#8221; Unexpected Tomcat Crash &#8211; Solved</title>
		<link>http://mentormate.com/blog/javalangoutofmemoryerror-java-heap-space-unexpected-tomcat-crash-solved/</link>
		<comments>http://mentormate.com/blog/javalangoutofmemoryerror-java-heap-space-unexpected-tomcat-crash-solved/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 17:07:14 +0000</pubDate>
		<dc:creator>Dimitar Dobrev</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tomcat]]></category>

		<guid isPermaLink="false">http://mentormate.com/blog/?p=35</guid>
		<description><![CDATA[Recently, we've been dealing with an issue related to our Tomcat Application Server and wanted to share how we solved this one. We found one that the application server was irrelevant (it could be Glassfish or another as well). The server was running the latest version, Tomcat Application Server 6.0.18, and it was crashing in irregular intervals. There was no easy solution because the server stopped making logs before crashing.]]></description>
			<content:encoded><![CDATA[<p>We started the usual things like upgrading the core components and making more logs that the Tomcat can output. After all these we got rows in the localhost log saying &#8220;java.lang.OutOfMemoryError: Java heap space&#8221; but with no other information like rows of code, etc. We continued to optimize the memory usage by flushing the input and output streams in the code and others. After that we received this log:</p>
<p><code>
<pre class="brush: plain;">SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.OutOfMemoryError: Java heap space
at java.lang.StringCoding$StringDecoder.decode(StringCoding.java:133)
at java.lang.StringCoding.decode(StringCoding.java:173)
at java.lang.String.(String.java:444)
at org.postgresql.core.Encoding.decode(Encoding.java:193)
at org.postgresql.core.Encoding.decode(Encoding.java:205)
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:1892)
at org.apache.tomcat.dbcp.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:175)</pre>
<p></code></p>
<p>This was the first time when we had a log where there was a specific row number indicating the error. After looking at the code, we found that the row was in logic, where we assign a field from the database to a string variable. It was nothing unusual, so we decided to check the field in the database table. It was a &#8220;text&#8221; field in a PostgreSQL database that we access using JDBC driver. After a SELECT length(‘field&#8217;) command, we estimated that the biggest field data is about 1 MB! So, if we wanted to take the whole table that would be about 400 MB data fetched in a single click that invoked this method. After that we were able to finally reproduce the server crash, clicking several times on the button that invoked the method fetching this abnormally large amount of data. We had to revise the code so that we take only one field when needed. This solved the crashing issue.</p>
<p>The lesson is that we need to make sure we are not requesting too much data using the SQL statements. Even if we are getting a small amount of columns like in this case, we need to have in mind that one of them could contain a lot of information and make the system crash – especially with lots of concurrent users.</p>
]]></content:encoded>
			<wfw:commentRss>http://mentormate.com/blog/javalangoutofmemoryerror-java-heap-space-unexpected-tomcat-crash-solved/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NetBeans Visual JSF editor tutorial on web applications running over HTTPS displaying warning in IE &#8220;This page contains both secure and nonsecure items&#8221;.</title>
		<link>http://mentormate.com/blog/netbeans-visual-jsf-editor-tutorial-web-applications-running-https-displaying-warning-page-secure-nonsecure-items-2/</link>
		<comments>http://mentormate.com/blog/netbeans-visual-jsf-editor-tutorial-web-applications-running-https-displaying-warning-page-secure-nonsecure-items-2/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 19:36:53 +0000</pubDate>
		<dc:creator>Dimitar Dobrev</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[netbeans]]></category>
		<category><![CDATA[visual jsf editor]]></category>

		<guid isPermaLink="false">http://mentormate.com/blog/?p=25</guid>
		<description><![CDATA[Developers who have used NetBeans 6.1 and 6.5 for web development with Visual JSF (Woodstock) might have encountered an issue with their web application when deployed on a secured server (HTTPS) and opened with Internet Explorer. The issue lies in the way IE treats links to JavaScript and CSS files loaded in the pages. Under HTTPS, the links to JavaScript have to be absolute, not relative. IE does not assume that the "relative" folder is secured.]]></description>
			<content:encoded><![CDATA[<p>If you &#8220;view source&#8221; on the page that Woodstock generates, you will see the following line:</p>
<p><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;"> </span></p>
<pre class="brush: plain;">&lt;/span&gt;&lt;code&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;/app/theme/com/sun/webui/jsf/suntheme4_2-080320/javascript/bootstrap.js&quot;&gt;&lt;/code&gt;&lt;span style=&quot;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;&quot;&gt;</pre>
<p>Now if you change that line to:<br />
<code><br />
</code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;"> </span></p>
<pre class="brush: plain;">&lt;/span&gt;&lt;code&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;https://www.yourserver.com:8443/ app/theme/com/sun/webui/jsf/suntheme4_2-080320/javascript/bootstrap.js&quot;&gt;&lt;/code&gt;&lt;span style=&quot;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;&quot;&gt;</pre>
<p>The site will now work under HTTPS without any security warnings. Obviously, this cannot be done straightforward because this piece of HTML code is generated by the Woodstock library. The solution we have implemented to resolve this problem is to change the code in the Woodstock library that generates the HTML header of the pages. The following solution is not the most elegant solution; it’s more of a simple workaround to solve this problem in production environment:</p>
<ol>
<li>Open the Woodstock project web site, https://woodstock.dev.java.net/index.html, and go to &#8220;Build it Yourself.&#8221;</li>
<li>Follow the instructions on the &#8220;Build it Yourself&#8221; page to register and get a CVS access to download the framework source code. The CVS URL will be something like: :pserver:username@cvs.dev.java.net:/cvs. You don’t need NetBeans 5.5, as it is written in the compile instructions.</li>
<li>Open the CVS repository with NetBeans and check out the module &#8220;woodstock/webui&#8221; and branch &#8220;Release42&#8243; as a new project.<img class="alignnone" src="http://mentormate.com/blog/images/netbeans-visual-jsf-tutorial-screenshot-1.jpg" alt="" width="628" height="445" /></li>
<li>Open the project and edit the &#8220;JavaScriptUtilities.java&#8221; file in package com.sun.webui.jsf.util in &#8220;src/runtime&#8221; folder.</li>
<li>In method &#8220;renderJavaScriptInclude&#8221;   change line 578 from:<code><br />
</code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;">
<pre class="brush: plain;">&lt;/span&gt;&lt;code&gt;String jsFile = getTheme().getPathToJSFile(file);&lt;/code&gt;&lt;span style=&quot;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;&quot;&gt;</pre>
<p>To:<code><br />
</code><span style="font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;"> </span></p>
<pre class="brush: plain;">&lt;/span&gt;&lt;code&gt;String jsFile = &quot;https://www.yourserver.com:8443&quot; + getTheme().getPathToJSFile(file);&lt;/code&gt;&lt;span style=&quot;font-family: Georgia,'Times New Roman','Bitstream Charter',Times,serif; font-size: 13px; line-height: 19px;&quot;&gt;</pre>
<p></span></li>
<li>Save the file and rebuild the project. During compile, you might notice a lot of warnings, etc – just ignore them.</li>
<li>Copy and overwrite the newly compiled webui-jsf.jar and webui-jsf-dt.jar from the Woodstock source code folder &#8220;woodstockwebuidist&#8221; to the NetBeans subfolder. &#8220;visualweb2modulesext&#8221;. Keep a copy of the original jar files (see below).</li>
<li>Rebuild your WAR file and deploy it on the HTTPS server.</li>
</ol>
<p>There you go. You should now have your website working under IE with no security warnings. Note that the newly compiled .jar files will work only on the server URL you define in Step 5. They won’t work in localhost development environment, so you might want to change with original .jar files during development phase. Cheers.</p>
]]></content:encoded>
			<wfw:commentRss>http://mentormate.com/blog/netbeans-visual-jsf-editor-tutorial-web-applications-running-https-displaying-warning-page-secure-nonsecure-items-2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
