You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Arikatla SreenivasaRao <ce...@gmail.com> on 2012/01/12 21:33:02 UTC

Migration of DB from DB2 to Oracle with Struts2

Hi,

My company is building a new application using Struts2 with database as
DB2.In future if I want to migrate my database to Oracle is it is
to Migrate.Somebody told it is easier in some frameworks. So is this
applicable to Struts2 as well.

If my purpose to migrate data from DB2 to Oracle in future what coding
processes I need to follow in Struts2 to make the migration smooth.

Or any other frameworks have edge in this aspect..Can you please share your
thoughts..

Thanks in Advance
Rao

Re: Migration of DB from DB2 to Oracle with Struts2

Posted by Dave Newton <da...@gmail.com>.
S2 doesn't have anything to do with the persistence layer.

Dave

On Thu, Jan 12, 2012 at 3:33 PM, Arikatla SreenivasaRao <
certainty.sreeni@gmail.com> wrote:

> Hi,
>
> My company is building a new application using Struts2 with database as
> DB2.In future if I want to migrate my database to Oracle is it is
> to Migrate.Somebody told it is easier in some frameworks. So is this
> applicable to Struts2 as well.
>
> If my purpose to migrate data from DB2 to Oracle in future what coding
> processes I need to follow in Struts2 to make the migration smooth.
>
> Or any other frameworks have edge in this aspect..Can you please share your
> thoughts..
>
> Thanks in Advance
> Rao
>

Re: File download fails in Firefox and Chrome

Posted by Struts Two <st...@yahoo.ca>.
Thank you very much for your reply. Your suggestion worked though in IE the file is opened in a new tab as opposed to save but it works on Firefox. 



----- Original Message -----
From: Eric Lentz <Er...@sherwin.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Cc: 
Sent: Friday, January 13, 2012 11:22:02 AM
Subject: Re: File download fails in Firefox and Chrome

> Not setting the Content-disposition is header, makes the firefox to 
prompt for the download but it uses the action for filename ie 
Ticket.action. > Has anyone faced a similar issue or can provide a hint on 
how to fix the issue

Yep, saw this problem just this week.

I ran the request through software that would allow me to view the header 
and I saw that only the filename appeared in the contentDisposition, no 
"filename="...
Add a field to your action class called contentDisposition and assign it 
like this:
contentDisposition = "filename=\"" + filename + "\"";

This assumes you are using the stream result in a manner similar to this:
        <result name="myDownloadName" type="stream">
                <param name="bufferSize">1024</param>
        </result>

I included the contentDisposition in the result like this:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${contentType}</param>
                <param 
name="contentDisposition">filename=${contentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

But that didn't work, because Struts took whatever was in my 
contentDisposition in my action versus using the param. So _the above 
doesn't work_ because it would drop the "filename=" portion. If you used a 
different variable name, then it would probably work, but I didn't go back 
and try. In theory, this would work:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${myContentType}</param>
                <param 
name="contentDisposition">filename=${myContentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

Assuming you had myContentType and myContentDisposition in your action.

Hope that helps. 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: File download fails in Firefox and Chrome

Posted by Eric Lentz <Er...@sherwin.com>.
> I was working with no issue until a month ago for over a year and 
suddenly it has stopped working

I get that. Best thing to do would be to view the headers from a client 
that can do so. There are plug-ins in Firefox that will allow that I 
believe. I think you'll find that something is amiss with the header even 
though it appears you have it set correctly. I see from your last e-mail 
that you have it fixed though, so moot point I guess.

Re: File download fails in Firefox and Chrome

Posted by Struts Two <st...@yahoo.ca>.
The fact is that I set content disposition programatically in the following line

getServletResponse().setHeader("Content-Disposition",
                ("attachment;filename=\"" + attachment.getName().trim().replaceAll(" ", "_") + "\""));
in the action as opposed to configuration. I was working with no issue until a month ago for over a year and suddenly it has stopped working



----- Original Message -----
From: Eric Lentz <Er...@sherwin.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Cc: 
Sent: Friday, January 13, 2012 11:22:02 AM
Subject: Re: File download fails in Firefox and Chrome

> Not setting the Content-disposition is header, makes the firefox to 
prompt for the download but it uses the action for filename ie 
Ticket.action. > Has anyone faced a similar issue or can provide a hint on 
how to fix the issue

Yep, saw this problem just this week.

I ran the request through software that would allow me to view the header 
and I saw that only the filename appeared in the contentDisposition, no 
"filename="...
Add a field to your action class called contentDisposition and assign it 
like this:
contentDisposition = "filename=\"" + filename + "\"";

This assumes you are using the stream result in a manner similar to this:
        <result name="myDownloadName" type="stream">
                <param name="bufferSize">1024</param>
        </result>

I included the contentDisposition in the result like this:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${contentType}</param>
                <param 
name="contentDisposition">filename=${contentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

But that didn't work, because Struts took whatever was in my 
contentDisposition in my action versus using the param. So _the above 
doesn't work_ because it would drop the "filename=" portion. If you used a 
different variable name, then it would probably work, but I didn't go back 
and try. In theory, this would work:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${myContentType}</param>
                <param 
name="contentDisposition">filename=${myContentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

Assuming you had myContentType and myContentDisposition in your action.

Hope that helps. 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: File download fails in Firefox and Chrome

Posted by Eric Lentz <Er...@sherwin.com>.
> Not setting the Content-disposition is header, makes the firefox to 
prompt for the download but it uses the action for filename ie 
Ticket.action. > Has anyone faced a similar issue or can provide a hint on 
how to fix the issue

Yep, saw this problem just this week.

I ran the request through software that would allow me to view the header 
and I saw that only the filename appeared in the contentDisposition, no 
"filename="...
Add a field to your action class called contentDisposition and assign it 
like this:
contentDisposition = "filename=\"" + filename + "\"";

This assumes you are using the stream result in a manner similar to this:
        <result name="myDownloadName" type="stream">
                <param name="bufferSize">1024</param>
        </result>

I included the contentDisposition in the result like this:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${contentType}</param>
                <param 
name="contentDisposition">filename=${contentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

But that didn't work, because Struts took whatever was in my 
contentDisposition in my action versus using the param. So _the above 
doesn't work_ because it would drop the "filename=" portion. If you used a 
different variable name, then it would probably work, but I didn't go back 
and try. In theory, this would work:

        <result name="myDownloadName" type="stream">
                <param name="contentType">${myContentType}</param>
                <param 
name="contentDisposition">filename=${myContentDisposition}"</param>
                <param name="bufferSize">1024</param>
        </result>

Assuming you had myContentType and myContentDisposition in your action.

Hope that helps.

File download fails in Firefox and Chrome

Posted by Struts Two <st...@yahoo.ca>.
Hi everyone:

I have an application in Struts 2.1.8 that has been running for the past two years with no issue. However; recently I have noticed the all file downloads on Firefox and Chrome fails while IE is okay. I know it has something with content-dispositon but  I have not been able to fix it. The code is as follows:




public String execute() {
        Attachment attachment = ticketLocal.findAttachment(getAttachmentId());
        setInputStream(new ByteArrayInputStream(attachment.getAttachment()));
        getServletResponse().setHeader("Content-Disposition",
                ("attachment; filename=\"" + attachment.getName().trim().replaceAll(" ", "_") + "\""));
        return Action.SUCCESS;

    }

Not setting the Content-disposition is header, makes the firefox to prompt for the download but it uses the action for filename ie Ticket.action. Has anyone faced a similar issue or can provide a hint on how to fix the issue


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Migration of DB from DB2 to Oracle with Struts2

Posted by Hernán <he...@gmail.com>.
To make your application available for migration to different Databases you
should use an Object to Relationship Mapping technology, such as Java
Persistence API or Hibernate, once you've developed an application that
way, you can just change the driver of the database and migrate to another
one... At the same time these technologies have tools to generate the
schema of the database... I recommend you to to use Spring as well, this
framework will let you inject dependencies, control security, transactions,
etc. Of course it is possible to integrate spring to struts2 and JPA or
Hibernate as well... Greetings.

On Thu, Jan 12, 2012 at 5:33 PM, Arikatla SreenivasaRao <
certainty.sreeni@gmail.com> wrote:

> Hi,
>
> My company is building a new application using Struts2 with database as
> DB2.In future if I want to migrate my database to Oracle is it is
> to Migrate.Somebody told it is easier in some frameworks. So is this
> applicable to Struts2 as well.
>
> If my purpose to migrate data from DB2 to Oracle in future what coding
> processes I need to follow in Struts2 to make the migration smooth.
>
> Or any other frameworks have edge in this aspect..Can you please share your
> thoughts..
>
> Thanks in Advance
> Rao
>



-- 
Hernán

Re: Migration of DB from DB2 to Oracle with Struts2

Posted by Eric Reed <ER...@MAIL.NYSED.GOV>.
Think of Struts as a flow control framework.. ie from one jsp or action class to another. Struts has no care in the world what your DB is. Your main concerns should be on the server side. 

BTW:

It is always cheaper and quicker to do things one step at a time the right way. For your company I would get my data to Oracle FIRST then proceed with making a nice user friendly web interface to said data.


>>> Arikatla SreenivasaRao <ce...@gmail.com> 1/12/2012 3:33 PM >>>
Hi,

My company is building a new application using Struts2 with database as
DB2.In future if I want to migrate my database to Oracle is it is
to Migrate.Somebody told it is easier in some frameworks. So is this
applicable to Struts2 as well.

If my purpose to migrate data from DB2 to Oracle in future what coding
processes I need to follow in Struts2 to make the migration smooth.

Or any other frameworks have edge in this aspect..Can you please share your
thoughts..

Thanks in Advance
Rao


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org