Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!

Franck Tranchant

Ranch Hand
+ Follow
since Aug 07, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Franck Tranchant

Just in case someone is interested, I find a simple way to do that using only RedirectMatch. Actually, RewriteCond + RewriteRule were not necessary.

Instructions below work fine :


So simple..

[ October 04, 2006: Message edited by: Franck Tranchant ]
13 years ago
Hi

I'm very new at mod_rewriting and i wonder how i could set up this kind of logic :

if (url.contains("aaa")){
redirect http://www.my_first_domain.com
exit
}
if (url.contains("bbb")){
redirect to http://www.my_second_domain.com
exit
}

Could someone give me the first steps ?
13 years ago
Thank you Eric, that's exactly what i was looking for.
I'll investigate the code behind this ;-)
Hi there

You may have heard about Meebo before (All-in-one web interface for IM protocols).

Do you have any idea about how they simulate the "windows" ??

For example, here is an alert pseudo-window :


Of course, this is not a real pop-up, only a customized <DIV> i suppose and it can be moved, it's resizable, the content area can scroll etc...

Heavy use of JavaScript/Ajax makes it very difficult to get the source so i wonder if someone know how to code something similar to this...

Any idea or suggestion is welcome

Thanx.
[ February 14, 2006: Message edited by: Franck Tranchant ]
Hi

Nothing special to do then :
In your struts-config file, leave your Action description without any name, so it won't be mapped to any Form.
Define the usual forwards and your Action will be available.

Example:

<action path="/MyAction" type="my.package.MyAction" input="input" scope="request">
<forward name="input" path="/input.jsp" />
<forward name="success" path="/myJSP.jsp" />
<forward name="error" path="/error.jsp" />
</action>
[ December 05, 2005: Message edited by: Franck Tranchant ]
14 years ago
Hi

I'm currently trying to code several basic behaviours in a struts based web app using AJAX technics.
It works fine and javascript actions such as updating part of a page without a whole page reload are awesome !

But, as soon as I deal with Form data, I'm facing some difficulties.
Since my javascript methods do not Post the Form, I cannot handle user's data so i'm forced to code extra stuff as walkaround in order not to loose data. It actually works but doesn't look good to me at all.

Do you guys know some good AJAX technics for a better integration with the Struts framework ?

Hope I'm clear enough.
If not, let me know
:-)

Thanx
Hi

As far as I know, no particular Struts tag for this particular behaviour.
It's up to you to display/hide your data.

You could maybe initialize a java variable (bean:define) reflecting the current role of the user.
Then, depending of the value of this variable, write the data (logic:equal) or do nothing (logic:notEqual) in the table header and in the table rows (into the logic:iterate, if you used one to display your list).

Hope it helps...
[ October 20, 2005: Message edited by: Franck Tranchant ]
14 years ago
Hi

Locale can be changed manually using Action's setLocale(HttpServletRequest, Locale) method.

Just use the lowercase two-letter ISO-639 language code and the uppercase two-letter ISO-3166 country code to build a locale then use the setter to modify the user's current selected Locale into it's Session.
14 years ago
Hi

If your action methods , including database access etc.. are executed twice, you can be 99% sure that your actions are actually called twice.
Incorrect use of javascript could explain that kind of behaviour.

Don't you have some javascript coded in your JSP's on events like onclick/onsubmit/image+href.. ?
If so, double-check the 'return' value to avoid your Form being posted twice.
14 years ago
Hi Meera

As Nathaniel previously said, all you need to do is to code a Struts Action that will take care of the picture 'retrieval', then call this action from the image tag of your JSP.

For exemple, you you might have a DisplayImageAction class with an execute method in it.
This action is supposed to return a stream of bytes, so you may set the returning type of the execute method to void instead of the default ActionForward since no forward is involved here.

Code the access of your stored procedure right into the execute method.
Basically, get a byte[] containing your picture, set the ContentType of your response (at least "image"), then send the bytes to your response outputStream (response.getOutputStream).

Once it's done, just call your Action from your JSP with basic HTML tag or Struts IMG tag. Don't forget to send a parameter in your request and use it in the Action to identify the file you need to retrieve :

<img src="displayImage.do?imageID=123" border="0">

Hope it helps...
14 years ago
Hi

I had to solve that kind of problem once.

Since I used a server without any native graphics resource (headless server), I choosed to use PJA Toolkit but you probably don't need it.

Anyway, you will find a sample code about how to generate a compressed picture (thumb) in this java class using extra API such as java.awt, javax.swing, com.sun.image.codec.jpeg etc..
15 years ago
Hi Julie

Actually, i can see 2 questions in your post:
1- how to display a picture stored in a database from a JSP,
2- how to provide a user the way to upload a picture.

Question 1 : See previous topic "Display image from Action class". It might help.

Question 2 : What do you exactly want. Upload file and simply store it on a file server ? Upload the file then insert it in your database ?
[ August 31, 2005: Message edited by: Franck Tranchant ]
15 years ago
Hiiii

From Struts Developer Guide :
"There are two ways you can append one or more dynamically defined query parameters to the hyperlink -- specify a single parameter with the paramId attribute (and its associated attributes to select the value), or specify the name (and optional property) attributes to select a java.util.Map bean that contains one or more parameter ids and corresponding values.

To specify a single parameter, use the paramId attribute to define the name of the request parameter to be submitted. To specify the corresponding value, use one of the following approaches:
- Specify only the paramName attribute - The named JSP bean (optionally scoped by the value of the paramScope attribute) must identify a value that can be converted to a String.
- Specify both the paramName and paramProperty attributes - The specified property getter method will be called on the JSP bean identified by the paramName (and optional paramScope) attributes, in order to select a value that can be converted to a String.

If you prefer to specify a java.util.Map that contains all of the request parameters to be added to the hyperlink, use one of the following techniques:
- Specify only the name attribute - The named JSP bean (optionally scoped by the value of the scope attribute) must identify a java.util.Map containing the parameters.
- Specify both name and property attributes - The specified property getter method will be called on the bean identified by the name (and optional scope) attributes, in order to return the java.util.Map containing the parameters.

As the Map is processed, the keys are assumed to be the names of query parameters to be appended to the hyperlink. The value associated with each key must be either a String or a String array representing the parameter value(s), or an object whose toString() method will be called. If a String array is specified, more than one value for the same query parameter name will be created."

Here is a basic example. Of course, in the real world, values added to the HashMap should be dynamic, and probably handled into an Action instead of the JSP :

Resulting HTML will be :
15 years ago