This week's book giveaway is in the Server-Side JavaScript and NodeJS forum.
We're giving away four copies of Micro Frontends in Action and have Michael Geers on-line!
See this thread for details.
Win a copy of Micro Frontends in Action this week in the Server-Side JavaScript and NodeJS forum!

Clarence Dyho

Greenhorn
+ Follow
since Sep 17, 2001
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 Clarence Dyho

Hello everyone,

The password for the database that out application is connected to changes every 2 weeks (as a security policy). The new database connection information is captured from the front end web app.

I want to know how I can dynamically change the password for our datasource connection without touching the JBoss DS files and/or restarting JBoss. Is there a standard solution to this? Thank you.

Regards,
Clarence
15 years ago
Thanks for you input.

Now that was embarassing. I'm shocked as to why I didn't think about that in the first place. I think I need a vacation

Thanks again.
15 years ago
Hello,

My JSP contains a link to download a CSV file from the server. The JSP path and filename are stored in the ApplicationResources properties file and is resolved at runtime. Clicking this link calls an Action that handles the download. When the file to be downloaded does not exist, the try-catch block returns a FileNotFoundException. My app works this far and the logs show that I do handle the exception.

My problem is that the file download box (the one with open/save/cancel button) still appears even when the file does not exist on the server. Clicking on "save" will save a new, empty file with the same filename of the file to be downloaded. "Open" opens a new file with the same name.

Another problem is that I cannot forward to the error page where the errors would appear in the <html:errors/> section. It's like the Download dialog prevents this from happening.

I appreciate your inputs on this. Thank you very much.

Regards,
Clarence

---code snippet----
...

File file = new File(path+filename);
response.setContentType("application/unknown");
response.setHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
long fileLength = file.length();
response.setHeader("Content-Length", new Long(fileLength).toString());

try{
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
ServletOutputStream stream = response.getOutputStream();
int data;
while ((data = bis.read()) != -1) {
stream.write(data);
}
bis.close();
stream.flush();
stream.close();
}catch(FileNotFoundException e){
...
}catch (Exception ex){
...
}
saveErrors(request,errors);
if(errors.size()!=0){
return mapping.findForward("fail");
}

...
-------------------
15 years ago
Thank you Bear and Nathan.

Due to the complexity of the change invloved, priority is now on other critical items and the feature has been defered. I will revisit this again.
I think Javascript is going to play a bigger role this time, coupled with the way Nathan described the likely scenario.

Thank you for your help. More power!
15 years ago
JSP
Hello,

Currently, my JSP calls an EJB service that returns a File object. I then display the contents of the file in the JSP. The file is just a regular text file generated by a logger. I have a refresh button that calls the same service and re-displays the latest contents of the file.

The specs were changed such that the users wants the refresh to be automatic (every 15 seconds, for example) but they do not want the overhead associated with calling the service, downloading the whole file, and displaying the contents. The display should be dynamic such that the updated portion will dynamically be "tailed" or appended to the existing contents in the JSP, much like the tail option when viewing files in Unix. The file could be several megabytes in size and they do not want to see the view going blank for a long time while the JSP tries to download and open the entire logfile.

My question is, is it possible to achieve this using pure JSP (and how) or should I be looking at something else such as Applets?

Thank you.

Regards,
Clarence
15 years ago
JSP
Thank you for your reply, Rovas.

Is there any workaround or any pattern to solve this problem?
16 years ago
JSP
Hello

I have an entry form. When the user clicks on submit, the information is stored into the DB and the user is sent back to the same form with an alert message informing him that the DB insert was successful. I set a request attribute that the JSP checks to see if the DB insert is successful. If so, then the alert message is displayed and then I remove the attribute from the request.

Using tokens, I was able to display the same page without the alert message when the user refreshes the page.

My problem is when the I click the back button and then press the forward button again, the alert message is redisplayed. It's like when I hit the back button, the attribute that I have set subsequently removed still persist.

What work arounds can I do to clear the attribute permanently from the request and prevent the alert from firing when I go back or forward a page?

I am using Struts framework BTW but I feel this is more on the JSP side.

Thank you very much.
16 years ago
JSP
Thank you again for your reply, Rovas.

I did something similar. Only I put them in my servlet instead of in my JSP :

response.setHeader("Cache-Control","no-cache");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", -1);

What happens is that the page expires when the back button is pressed. Not the most elegant solution but it should work for now. Thank you for your help.
16 years ago
JSP
Thank you Marc. It worked! And Struts has built in classes to handle it too!

Thanks so much,
Clarence
16 years ago
Hello,

I have a page where a user can edit his contact details. When the user clicks on the update button on that form, the update action writes the info to the database and forwards the user to a success page.

My problem is that when the user refreshes the sucess page (F5 or the refresh icon in IE), the update action class gets called again. The same thing happens when the user presses the back button the press the forward button again.

Is there a way I can code the action (or the JSP page) to clear attributes or forwards? Thank you.


regards,
Clarence
16 years ago
Aitor, Thank you for your reply. It works now.

The problem lies with the hostname that I am using. I am using "localhost" instead of the hostname of my machine. Hence, when my webApp tried to look for the EJBs in the other server, it encountered localhost and attempted to look for the EJBs from within the local container. I then get a NamingException.

Again I appreciate all your help
Hello

Instead of running Websphere on 2 physical servers (my earlier post), the project team now wants to run 2 instances of WebSphere on a single machine.

I have my web app running on one instance and my EJBs are deployed on another instance. My question is how can I lookup and create the EJBs on the other instance from my web app. I've tried using the JNDI name generated by Websphere but I kept on getting:

NamingException
First component in name <JNDI Name> not found.

My apologies if the problem sound so basic. I'm a newbie when it comes to EJBs as I've tried to stay away from them due to complexities such as this.
Thank you.

Clarence
Thank you Brian.

I have gotten this far too. My problem now is with the JNDI names.
Whereas I was using "java:comp/env/someName" for the lookup before, I can't use it now.
I tried using the full JNDI binding name of the remote EJB but I kept getting the following error:

Context: localhost/nodes/localhost/servers/server1, name: ejb/MsmServiceBnMgr: First component in name MsmServiceBnMgr not found.


The app servers are not clustered. We are now looking into putting both app servers into 1 machine but running on separate JVMs. I think I would still have the same problem. Any further information is greatly appreciated.
Thank you for your response Adrian.

No. The servers are not clustered. My app just need to call the EJBs deployed in another Websphere server across the network. I'm not sure how to call them or set up the deployment descriptors for my app to find the EJBs.
Hello,

My web app works if the sessions beans being called are deployed in the same websphere container/server instance. I'd like to know how I should rewrite/configure the JNDI lookup in my codes to use the EJBs if they are deployed in another webSphere (or other app server) instance separately from my webapp within the same network. Apparently, the java:comp/env/.. lookup string does not work anymore. Is this something that I could setup in my EJB deployment descriptors or do I have to do some tweaking in the app server and leave my codes as is? Any examples would be welcome. Your response is greatly appreciated.

Thank you.
Clarence