Win a copy of Terraform in Action this week in the Cloud forum!

Servin Park

Greenhorn
+ Follow
since May 10, 2002
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 Servin Park

Hello ranchers,

I am building a web application in Korean. Everything went smoothly while developing the app in my desktop (win xp, mysql, tomcat 5.x).

I deployed my app in a web hosting company that supports servlet/jsp when I thought I am pretty much done. I spoke too soon. I am struggling for a week to figure out a way prevent Korean letters to displayed correctly. I am not having any luck with it at all.

I have developed html docs using euc-kr charset and used the html as a jsp base. Each page contains Korean and English.

I enter a paragraph in Korean from a form I created. I would go to the mysql database to see if what I entered is in correct format. And it is in correct format. And then if I retrieved the paragraph from the database, it is all broken when displayed in my jsp.

Can anyone help?
16 years ago
JSP
Hello all,
I bought a package from a Web Hosting Company and am building a webapp that can serve as a community news site. what I would like to accomplish is this:
1. Editors can add, modify their columns any time they want.
2. Readers can read the most up-to-date information all the time.
I thought about two solutions:
1. Each time an editor add a column (essay, news, information, events, etc.), write a html file in a designated folder. When a user accesses particular page, just include the html in the jsp. I just need to figure out a way to sort all the html out so that they get included correctly.
2. Save all the columns in database. When a user accesses particular page, get the content from a table in the database.
The first solution will work fine for me, but I don't like too much File I/O happening in the server. The second solution will work fine also, but concerned about database usage. It appears to me that every user click will require database connection, query, etc...
What do you think? If you have better solution or comment about any of my solutions, please drop me a note.
Many thanks in advance for your help.
18 years ago
Hello,
Use loginCookie.setMaxAge(1); instead of loginCookie.setMaxAge(0);
It was bothering me for a while and someone told me of this trick. try and let me know
18 years ago
Hello Ranchers,
I am building a webapp on top of struts. I also have a DBConnectionPool class that will handle getting MySQL database connection. I just want to ask your opinion on what I am doing has any flaw:
1. Extended ActionServlet and override init(...) method. In the init() I initialized conncetionpool and servletContext.setAttribute("dbpool", dbconn);
2. In the action class (for instance RegisterAction), I get the connectionpool like this. getServlet().getServletContext().getAttribute("dbpool");
I didn't get any problem having me as only user. Does anyone see flaws in my logic above? Do you have any better idea how to utilize generic connection pool with struts?
Thanks in advance for you kind replies.
18 years ago
Hello all,
I am building a webapp with MVC pattern. In my controller servlet, I need to register eventHandler classes for later use. Following are two options that I can think of:
1. Declare "private HashMap eventHandler" class level variable and in the init(...) method initialize the eventHandler variable with every event handler classes using reflection eventHandler.put(key, ((EventHandler) Class.forName(value).newInstance())). And get appropriate event handlers depending on request parameters.
2. Set up a method that returns appropriate event handler in the controller servlet using switch():
...
A major difference I can think of between those two options is number of times Class.forName(..) method is called. First option calls the Class.forName(..) method once for every eventHandler for the life of the servlet. Second option call the Class.forName(..) method every time there is request. Which one of those options is "better practice"? Is there any obvious flaw in logic? Is there "better practice" that those options? Many thanks in advance for your input.
19 years ago

Originally posted by William Brogden:
1. I don't see any reason to synchronize on the session.
2. Where do you recover a possible cookie from previous visits?
3. Setting the session max inactive interval to -1 means to never time out. If your servlet engine serializes sessions to a file, it would stick around forever - you might end up with lots of orphan sessions.
I don't think it has anything to do with the lifetime of the cookie on the browser that associates the browser with that session, but I might be wrong. If the browser forgets the session ID, where are you?
If you are going to deal with a lot of visitors, seems to me you need a database.
Bill


Thank you Bill as always.
Let's forget about what I wrote previously. I just want to accomplish the functionality that let's users enjoy his/her preference when they visit my site. Following are more questions I have:
Assumpsion: Users will have enabled Cookie.
1. Can you modify Cookie object that has already been created? For instance, a user wants Red to be the color of her page which, in turn, creates a cookie with color=red. A few days later she wants to change the color to Blue. Can the existing cookie be changed so that it now contains color=blue?
2. If above is possible, response.addCookie(cookie); should be called even if I am not adding NEW cookie?
3. Do you have any other/better idea how to accomplish the functionality?
I guess what I am trying to do is just like what http://my.yahoo.com is doing. It let's me customize my own yahoo home page. Once it is done, it doesn't ask me to login all the time and I can still make changes as much as I want.
19 years ago
Hello javaranchers,
I am building a webapp where users can customize colors (Blue or Red) of pages to their likings.
My code looks like following:

Would this code work? My intension was to keep the preference for long time, so when tehy come back, the color would be what they chose a couple weeks ago. Quesions:
1. Will setting session.setMaxInactiveInterval(-1) will persist after closing the browser? Which means, I don't have to use Cookie. I could create a simple preference class to specify color preference and set it as attribute.
Any ideas or opinion would be greatly appreciated. Thank you
19 years ago
Hello,
I am building a webapp using MVC pattern, servlet as controller, jsp as view and javaBeans as model.
My webapp will let editors to modify or add new columns or essays as they please. My plan is to create or modify existing
html file with their writings and just include( <jsp:include ...> ) those files in jsp. However, I am having
trouble writing files in servlet. For instance, following code
...
File temp = new File("\column.html");
temp.createNewFile();
...
creates column.html in C:\column.html. what I what is to be able to create html files in the same level as WEB-INF directory and let jsp include them with no problem. Many thanks in advance for your help
19 years ago
Hi all,
I am building a webapp using servlet/jsp with mySql. My question is "How to handle big articles from editors"
For instance, beginning of every week, my sports column editor updates content of the "Sports Section". I would like to make it so that the editor can type his column into a textarea (only the editor has access to) and click submit button to update the content. In behind the scene, I would use servlet and jsp to update the page (all visitors have access to) dynamically. What would be the most efficient way to store the content, which can be more than 1,000,000 characters, and make a call from servlet or jsp to update the page? I can only think of using "BLOB" data type in the database, but it somehow doesn't sound so appealing. Is there any other way that you could think of?
19 years ago
Thank you so much for your kind suggestions/comments.
19 years ago
My question may seem very silly, but bare with me please. In doGet or doPost method in a servlet that doesn't implement SingThreadModel, I instanciate an object called "MyObject".
1: public void doGet(...)
2: {
3: MyObject mo = new MyObject();
4: ...
5: //using set methods in MyObject, mo is
6: //customerized for each users that call
7: //this servlet
8: process(mo);
10: }
11:
12: private void process(MyObject mo)
13: {
14: //do something with mo
15: }
Let's say a split second later first request came in second request came in to the doGet method. By the time the first request is on the line 8, how do I know that the second request didn't changed the mo object? How do I make sure that the integrity of mo is kept? I read from somewhere that local variables and the parameters are threadsafe, but I just can't seem to understand it. Can someone explain what really happens or how it should be coded?
[ August 19, 2002: Message edited by: Servin Park ]
[ August 19, 2002: Message edited by: Servin Park ]
19 years ago
Hello,
I am building a wepapp with two servlets (InsertServlet and SelectServlet) that add and retrieve data from database. Since multiple users are going to use this app, I want to make sure each add and retrieve requests don't step on each other. I know I can implement SingleThreadModel for both servlets, but I want to look for alternatives. Any comments or examples will be greatly appreciated. Thank you.
19 years ago
I have a windows app that is very un intuitive and I began researching how to make a utility app using java. The windows app (let's call it winApp from now on) command line input and generates response. For instance, if I type "PARK/SERVIN" and press enter, the winApp will response with a list of orders that I placed. Following is roughly how the winApp screen looks like:
***********************************
!-- winApp starts --
PARK/SERVIN>
JAVA HOW TO USD34.00 REF12345
EJB HOW TO USD50.00 REF2345
TRACK REF12345>
SHIPPED ON JUL3
.
.
.
***********************************
Lines with ">" at the end are user typed commands and the rest are system responses. I built JNI app which sends user commands to the winApp using Swing classes to make user interface friendly. However, I am faced with a few problems. My JNI app cannot capture the winApp responses, which is very critical. Someone from this forum told me to try class Process (getInputStream() and getOutputStream()) to send commands and receive responses from to the winApp. I think this is better way, if possible, than JNI app. What I want to accomplish is:
1. Execute the winApp using Runtime.getRuntime().exec("winApp") to get Process object.
2. From the Process object get InputStream and OutputStream and send and received information.
3. Place a JTextArea in a Frame that shows sent and received information.
Is it possible? Can anyone give me some pointers on the step2 and 3 above?
Many thanks in advance for you help.
19 years ago
Hello again,
I would like to dynamically populate 2nd JComboBox depending on the option chosen in the first JComboBox. For instance, comBo1 contains Fruit, Vegetable. If I select Fruit, comBo2 is populated with Apple, Pear, Peach... If I select Vegetable, comBo2 contains Onion, Lettus, Broccoli... Many Thanks in advance.
19 years ago
Hello,
Is there a way to make a frame System Modal in java? So that my frame will stay on top always.
19 years ago