Sergey Kargopolov

Ranch Hand
+ Follow
since Jul 04, 2003
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Sergey Kargopolov

Rakesh, thank you very much for your post.

I am sorry, may be I did not describe my problem clear enough but I cannot find an example that folds and unfolds GWT Tree by selecting or clicking on Tree Item. I cannot find SelectionEvent example. Clicking on "+" is not what I am interested in. I need Tree to unfold and fold when users clicks on TreeItem. Code that I posted above does not work as I expect it to work. An event is triggered twice.

Thank you.
13 years ago
GWT
Hi!

I am having difficulty with Expanding and Folding the GWT Tree.

When user selects TreeItem with a mouse click I want the Tree to expand. And when user clicks on TreeItem again I want the Tree to Fold. The problem is that if I click on TreeItem when Tree is unfolded it Folds, and then immediately unfolds again. Looks like SelectionEvent is triggered twice . Here is my code:


public void onSelection(SelectionEvent<TreeItem> event) {
TreeItem t = event.getSelectedItem();
boolean isOpen = t.getState();

if(isOpen)
{
t.setState(false);

} else {
t.setState(true);
}
});

Please advise me...

Thank you.
13 years ago
GWT
I have tried that Steve!

In fact when I move the siteMenu.jsp to the same directory level as pages that include it or into a subdirectory then <jsp:include> works properly.

So, if I make a copy of siteMenu.jsp and place it on the same directory level then this works!

<jsp:include page="siteMenu.jsp"/>

When I move siteMenu.jsp into a subdirectory then it also works!

<jsp:include page="inc/siteMenu.jsp"/>

but when I place siteMenu.jsp to an upper level directory then it stops working...

<jsp:include page="../inc/siteMenu.jsp"/> or <jsp:include page="/inc/siteMenu.jsp"/> do not work!


I need siteMenu.jsp to be located in one upper directory or WEB-INF so that any page of web application can access it from any directory.

This behavior is only when requests are directed to JSP web application via Apache mod_jk. If I open web application in Tomcat as Stand along container/web server. Then jsp:include works properly and includes files from upper or lower level directories no problem.

Any thoughts?

13 years ago
Hi Steve!

Thank you very much for your reply!

What you are suggesting makes perfect sense. Here is what I have tried. Please have a look if I am getting you correctly.

The location of the page that includes "siteMenu.jsp" is at www.doman2.com/photo/index.jsp

Here is what I've tried:

<jsp:include page="'/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2/WEB-INF/inc/siteMenu.jsp"/> -- Does not work
<jsp:include page="http://www.domain2.com/WEB-INF/inc/siteMenu.jsp"/> -- Does not work

Then I tried using @ include and got an error message:

<%@ include file="../WEB-INF/inc/siteMenu.jsp" %>

org.apache.jasper.JasperException: /photoView.jsp(61,3) File "/../WEB-INF/inc/siteMenu.jsp" not found


Steve, what am I doing wrong?


13 years ago
Hi!

I am getting an Error message when downloading attachment from Gmail. Any image file that I download throws com.sun.mail.util.DecodingException:

com.sun.mail.util.DecodingException: BASE64Decoder: Error in encoded stream: needed 4 valid base64 characters but only got 3 before EOF, the 10 most recent characters were: "rOLsVOnCzb"

Even though an Exception is thrown downloaded file can be opened and viewed. But not good for scaling...

Please advise me what can I do to download file without DecodingException?

Thank you!


InputStream input = bodyPart.getInputStream()
String fileName = bodyPart.getFileName();

FileOutputStream fos = new FileOutputStream(fileName);
BufferedOutputStream bos = new BufferedOutputStream(fos);
BufferedInputStream bis = new BufferedInputStream(input);

byte buf[]=new byte[1024];
int aByte;
try
{
while ((aByte = bis.read(buf)) >0) {
bos.write(buf,0,aByte);
}

} catch(Exception ex)
{
ex.printStackTrace();
} finally{
bos.flush();
bos.close();
bis.close();
}
14 years ago
Has anyone come across this situation? please advise me... Where is mistake? What do i do wrong? I read Tomcat 6 documentation and searched the web for examples of integration Apache with Tomcat and it looks to me that I did the integration correctly. If the above mentioned configuration is correct then why would JSP be not able to include other JSP pages from upper directories?

I double checked!!! If I use mod_jk and Apache as front server then JSP can include any other JSP pages from sub directories. But cannot include any other JSP from upper directories.

<jsp:include page="WEB-INF/siteMenu.jsp"/>----- this works well!
<jsp:include page="inc/siteMenu.jsp"/>----- this works well!

<jsp:include page="/WEB-INF/siteMenu.jsp"/>----- does not work!
<jsp:include page="../WEB-INF/siteMenu.jsp"/>-----does not work!
<jsp:include page="../inc/siteMenu.jsp"/>-----does not work!

But if I access JSP web application with Tomcat as Stand along then jsp:include works properly and no problems appear.

Please advise me how to resolve this situation.?

Thank you!

Thank you.
14 years ago
Tried using ajp instead of mod_jk to see the difference and now I am getting an error message:

You do not have permission to access / on this server

<VirtualHost *>
DocumentRoot "TOMCAT/webapps/domain_2"
ServerName "www.domain2.com"
DirectoryIndex index.jsp
ProxyPreserveHost On

ProxyPass /* ajp://localhost:8009
ProxyPassReverse /* ajp://localhost:8009

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</VirtualHost>
14 years ago
Hello!

I am having a situation which I cannot understand and resolve.

I have configured Apache+mod_jk+Tomcat. Apache Web server hosts PHP web sites only and Tomcat hosts JSP web sites only. Almost everything works well but jsp:include stoped working properly!!!


Using VirtualHosting I configured:

domain_1.com - is processed by Apache
domain_2.com - is processed by Tomcat(both static content and JSP/Servlets)

In domain_2.com JSP is working well, Servlets are working well. But jsp:include stoped working properly!!!

For example:
index.jsp includes siteMenu.jsp

<jsp:include page="WEB-INF/siteMenu.jsp"/>----- this works well!

but other pages located in subfolders cannot access WEB-INF

<jsp:include page="../WEB-INF/siteMenu.jsp"/>----- does not work. Cannot find the file..
and
<jsp:include page="/WEB-INF/siteMenu.jsp"/>----- from subfolders does not work ....

But if I access web sites using Tomcat only - not via Apache and mod_jk, then the Web site is working properly and all pages are included properly. No code modification needed.

Please advised me what did I configure wrong? How to fix this?


#worker.properties file
workers.tomcat_home=/mnt/ebs/apache-tomcat-6.0.14
workers.java_home=/usr/java/jdk1.6.0_21
worker.list=ajp13

worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13

#server.xml

<Host name="www.domain_2.com" appBase="webapps/domain2"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
<Context path="/" docBase="/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2"/>
</Host>


# Configure mod_jk in httpd.conf
#
LoadModule jk_module /etc/httpd/modules/mod_jk.so
JkWorkersFile /mnt/ebs/apache-tomcat-6.0.14/conf/worker.properties
<VirtualHost *>
DocumentRoot "/mnt/ebs/apache-tomcat-6.0.14/webapps/domain2"
ServerName "www.domain_2.com"
DirectoryIndex index.jsp
JkMount /* ajp13
</VirtualHost>

Thank you!

14 years ago
Tim, thank you very much for your reply!!!

I am going to look into Tomcat Valve now and then PrettyFaces and then make a decision on which way to go.

I now see there are three ways to ago about rewriting or controlling URLs in Java Web Application with Tomcat:

1. Use Filter
2. Possibly Tomcat Valve(don't know. Need to read about)
3. Put Apache web server in front of Tomcat and use Apache mod_rewrite

Please advise if there are other options.

Thank you!

Sergey
14 years ago
Is there mod_rewrite in Tomcat when used as stand along web server?

I have a web application developed with JSP/Servlets and I need to SEO optimize it’s URLs. In Apache web server there is a mod_rewrite used to rewrite URLs and make them SEO friendly. How is it usually done in Tomcat when it is used as Stand along web server?

Looking for a solution I came across this project http://tuckey.org/. It looks good but I never used it so I am looking for an advise. When using Tomcat as stand along web server what is a proper or usual way to rewrite URLs to make them SEO friendly?

Thank you!
14 years ago
I got it working only by creating and using my own Convertor:

public class AnyStringToInteger implements Converter{
public Object getAsObject(FacesContext context, UIComponent component, String value) {
try{
return Integer.valueOf(value);
}catch(Throwable t){
return new Integer(0);
}
}

public String getAsString(FacesContext context, UIComponent component, Object value) {
return String.valueOf(value);
}
}


if not this Convertor, it does not work. Integers(Objects) are not allowed as values in SelectItem if standard Convertors are used.
[ February 12, 2007: Message edited by: Sergey Kargopolov ]
17 years ago
JSF
J Haley,

thank you very much for your kind explanation. I really thought that Facelets are same Java Server Faces and there is no difference. And Facelets it is just the way Java Server Faces are called. Just like Midlets, Servlets and Portlets pages written using Java Server Faces are called Facelets.

I am actually very new to JSF and it is my third week working on a project that requires me to write some JSF. I will definetly aquaint myself with http://facelets.dev.java.net/ and with Facelets tonight when I get couple of free hours after putting my kids to sleep .

Thank you.
17 years ago
JSF
I put <h:message for="selectManyListBox"/> to see if there is an error and there is one.

I get Validation Error: Value is not valid when form is submited.
17 years ago
JSF
The problem is still there... I just cannot figure it out.

If value is set to Integer the actionListener and action method does not get called. Everything starts working when I change the value to String.

In this example SelectManyListBox displays correctly but actionListener method is not called.

public SelectItem[] getTestValues()
{
SelectItem[] values = new SelectItem[1];
SelectItem item = new SelectItem();
item.setValue(new Integer("1"));
item.setLabel("Test");
values[0] = item;
return values;
}

This eample is 100% working


public SelectItem[] getTestValues()
{
SelectItem[] values = new SelectItem[1];
SelectItem item = new SelectItem();
item.setValue("1")
item.setLabel("Test");
values[0] = item;
return values;
}

Where could be the problem?
17 years ago
JSF
It is interesting but c:import works in my JSF pages. Ofcourse I need to import JSTL tag library. Otherwise JSF page will not be able to understand c:import.

<c:import url="WEB-INF/includes/userLogin.jsp"/>

I can also use JSP includes to include content into my JSF pages. <jsp:include page=""/>. Have you tried that?

make sure you put your included content into <f:subview> as shown in the examle/message above.

you can also use jsp directive(<%@include %>) to include your content into JSF pages.
17 years ago
JSF