2014年5月14日星期三

ThreadLocal causing memory leaks ?

code is as follows :
public class DateUtil {
private static ThreadLocal sdf = new ThreadLocal () {
protected DateFormat initialValue () {
return new SimpleDateFormat ("yyyy-MM-dd");
};
};


public static DateFormat getDateFormat (ThreadLocal tl) {
return tl.get ();
}
public static String format (Date date) {
if (date == null) {
return "";
} .
return getDateFormat (sdf) format (date);
}



public static Date parse (String st) throws ParseException {
return getDateFormat (sdf) parse (st).;
}
}

recently doing a Web project , because SimpleDateFormat is not thread- safe, so think of using ThreadLocal to encapsulate a moment , the project uses a thread pool , colleagues say such written words will cause instance of an object can not be recycled , leading to memory leaks, (ps: my colleagues said ThreadLocal thread-safe is not to solve the problem ) want to look at the big cattle , so in the end be able to use the line , if it will lead to memory leaks, I beg you analyze it.
------ Solution ---------------------------------------- ----
first, you write will not cause a memory leak or a problem instance of an object can not be recycled .
your colleague said , ThreadLocal is not to solve the problem of thread safety is also wrong to say , ThreadLocal is another idea , I think you should also know that I will not elaborate . When I say
memory leaks , and I do not see any problem, as worry about your colleagues, I think he probably felt every ThreadLocal sdf are placed in different Thread , if Thread not to be destroyed has been present in the memory of it, it still needs to look at the project and see a thread-safe and memory , there is no need for such strict on both sides , which side can regress it.
------ Solution ---------------------------------------- ----
personally think that as long as the life cycle of your thread is not long , absolutely no problem , JDK7 of ThreadLocalRandom is a similar approach.

If you feel insecure , you can add a remove method , finally ending in the block method execution ThreadLocal.remove


or your colleagues say is right , ThreadLocal more thread context is used to store information related
------ Solution ------------- -------------------------------
exhausted themselves release it.
------ Solution ---------------------------------------- ----
DateFormat is merely a tool , why should the thread isolate it?
------ Solution ---------------------------------------- ----
be synchronized static method , the direct use of DateFormat, simple and brutal and effective.

your colleagues worry , may be afraid of the page when a large amount of concurrent requests , each request must be assigned a ThreadLocal, will take up a lot of memory. As for recycling, feel ThreadLocal an end of the thread , and it will be over.
------ Solution ---------------------------------------- ----
colleagues say that this write words will cause instance of an object can not be recycled , resulting in a memory leak

Why do you ask your colleague next . Why not say that there is no basis for his conclusions .

As for you, I do not see what's the problem
------ Solution ------------------------- -------------------
Why are so easy to use memory leak it? java general code at best memory overflow. . . .
------ Solution ---------------------------------------- ----
looked under the landlord 's title , this deal is feasible. There are a few suggestions:
1, DateFormat insecurity occurs when multiple threads call the same result DateFormat instance , while we are all written in the general string parsing tools in the tool class methods , new SimpleDateFormat parse this there is no question of the thread , if the landlord does not involve particularly large web projects date parsing operation , no need to do too much handling .
2, the landlord using ThreadLocal encapsulation , so that each thread will contain a Dateformat instance , this can indeed solve the thread-safety issues , after all, between Dateformat separate thread , but the landlord a little note , ThreadLocal declarations follow the current cycle threads, also said the landlord with a thread pool , so used to put back into the thread pool thread , which is after every user access , Threadlocal did not release the memory leak does count , remember exhausted remove ( you can the return filter chain carried remove, ps: there is no other better place , if you run the code on the remove, it is not as efficient method 1 ) .
3, ThreadLocal to save data in the context of the main thread , the thread safety as for solving the problem , seemingly does not matter much , but the clever use can be resolved, the landlord 's example also illustrates this point .
------ Solution ---------------------------------------- ----
personally feel that this class should not exist ThreadLocal best not to use SimpleDateFormat not thread safe if you want to use this to parse then every times on the new accounting did nothing so much space if you just want to format it can use commons of FastDateFormat thread safety
------ For reference only ---------------------------------------
but also that thing seems csdn when I did not ask .
------ For reference only -------------------------------------- -

ask questions if you do not manually release the memory leak it appears , read a lot of information on the Internet and some say there may be some said it would not exist , really confused ?
------ For reference only -------------------------------------- -

Well, he said the usage is correct, but this seems to be using it, after all, is a solution Well ,
------ For reference only ---- -----------------------------------

Well , I feel that using a thread pool , that thread back into the thread pool runs out after other requests continue to be used , the corresponding object instance Sdf it has always existed in this thread ThreadLocalMap inside, so what does not seem to have a memory leak problem.
------ For reference only -------------------------------------- -

but this tool is not thread -safe, multithreaded simultaneous access to an instance problematic .
------ For reference only -------------------------------------- -

This fall is also a good solution.
------ For reference only -------------------------------------- -

since even the moderators are saying , it seems that it is feasible to write , then do not worry about it , or so use it ,
------ For reference only --- ------------------------------------
then hang the day tomorrow to tie knot points .
------ For reference only -------------------------------------- -

but this tool is not thread -safe, multithreaded simultaneous access to an instance problematic .  
Oh , SimpleDateFormat class

public Date parse(String text, ParsePosition pos)
{
        calendar.clear(); // Clears all the time fields

        ......//对calendar的一些操作

        else parsedDate = calendar.getTime();
}

thread safety hazard reason is the calendar thread shared.
brutally simple solution is to use the code synchronized SimpleDateFormat
There is ThreadLocal, let SimpleDateFormat threads localization ( each thread has its own copy of SimpleDateFormat, course calendar will not be shared between threads of the ) .

But I have a question :
landlord did not know specifically how to use your DateUtil of this class . This class does not inherit seemingly Thread or achieve Runnable.
So when you use DateUtil getDateFormat , seemingly out every time a new SimpleDateFormat, did not use the features ThreadLocal ah.

private static ThreadLocal sdf = new ThreadLocal () {
protected DateFormat initialValue () {
return new SimpleDateFormat ("yyyy-MM-dd");
};
};
above , your code should be written in a thread class in it, instead of writing instruments in this category


------ For reference only ---------------------------------- -----

but this tool is not thread -safe, multithreaded simultaneous access to an instance problematic .          
Oh , SimpleDateFormat class   
  

public Date parse(String text, ParsePosition pos)
{
        calendar.clear(); // Clears all the time fields

        ......//对calendar的一些操作

        else parsedDate = calendar.getTime();
}
  
thread safety hazard reason is the calendar thread shared.   
brutally simple solution is to use the code synchronized SimpleDateFormat   
There is ThreadLocal, let SimpleDateFormat threads localization ( each thread has its own copy of SimpleDateFormat, course calendar will not be shared between threads of the ) .   
  
But I have a question :   
landlord did not know specifically how to use your DateUtil of this class . This class does not inherit seemingly Thread or achieve Runnable.   
So when you use DateUtil getDateFormat , seemingly out every time a new SimpleDateFormat, did not use the features ThreadLocal ah.   
  
private static ThreadLocal sdf = new ThreadLocal () {   
protected DateFormat initialValue () {   
return new SimpleDateFormat ("yyyy-MM-dd");   
};   
};   
above , your code should be written in a thread class in it, instead of writing instruments in this category   
  
 
This is a utility class Well , if a request corresponds to a thread a, when I called DateUtil the format methods or parse method in which this request, if this thread is When first visit In this way, the thread will be stored in a corresponding member variable ThreadLocalMap a key for the above class member variables and values ​​of a new ThreadLocal SimpleDateFormat created after the end of this emphasis , the request corresponding to the thread pool thread will be recycled inside . For the other emphasizes the use , if that other person is also launching a page emphasizes , also assigned to this thread just a, then it will go directly to a member variable ThreadLocalMap it to ThreadLocal object has been stored for the key to get into the SimpleDateFormat.
In other words corresponding to each thread in the thread pool inside , will create a SImpleDateFormat object only when the first call DateUtil way inside , and store it in a thread inside ThreadLocalMap , and later it was stress when assigned to take on that thread directly from ThreadLocalMap inside, avoiding the overhead of each call are new , this will be between singleton with prototype , my personal understanding is such inadequacies look large cattle a lot of guidance .
------ For reference only -------------------------------------- -
meaning of the landlord is to give each thread by injecting a ThreadLocal sdf DateUtil tools do ?
------ For reference only -------------------------------------- -



not give each thread inject a sdf, but to each thread creates a SimpleDateFormat instance , the member variables are stored inside in Thread
ThreadLocalMap the value of , map the key to sdf.
------ For reference only ----------------------- ----------------

your second point , I do not quite understand , ThreadLocal is not released , but only this one instance ThreadLocal object memory, all the threads are not sharing what this ThreadLocal instance , only the corresponding SimpleDateFormat with different threads and different, so do not feel the release did not affect it ?
------ For reference only -------------------------------------- -

your second point , I do not quite understand , ThreadLocal is not released , but only this one ThreadLocal object instance in memory, all the threads are not sharing what this ThreadLocal instance , with just the corresponding SimpleDateFormat different threads and different, so do not feel the release did not affect it ?   ah indeed no impact , but your colleague is not to say what a memory leak , so I said above, is considered a memory leak , after all, you do not run out of the release .
------ For reference only -------------------------------------- -
Thank you for the advice , the problem has been solved, ready to stick to the end of it.

java read json format data

{
    "status":0,
    "message":"ok",
    "results":[
        {
            "name":"重庆秦妈火锅(马仁山东路店)",
            "location":{
                "lat":31.312634,
                "lng":118.406372
            },
            "address":"弋江区马仁山东路275号(南瑞世纪联华超市向东200米)",
            "telephone":"0553-5919177",
            "uid":"d01b6bf9e9ea6f9e4d776e95",
            "detail_info":{
                "type":"cater",
                "tag":"火锅,餐饮",
                "detail_url":"http://api.map.baidu.com/place/detail?uid=d01b6bf9e9ea6f9e4d776e95&output=html&source=placeapi_v2",
                "price":"45",
                "overall_rating":4.5,
                "service_rating":2,
                "environment_rating":4.5,
                "image_num":"30",
                "groupon_num":4,
                "comment_num":"283"
            }
        }
    ]
}
json data in this format I've used java code form part of the data read out, but the data location and detail_info I know these two parts should be used JSONObject to read, but I do not know how to write , here is what I wrote to read other data in addition to location and detail_info two
    public static void main(String[] args) throws IOException {
        JSONArray jsonArray = searchLocation("芜湖");
        Iterator iteratorArray = jsonArray.iterator();
        while (iteratorArray.hasNext()) {
            JSONObject json = (JSONObject) iteratorArray.next();
            String results = json.getString("results");
            JSONArray resultArray = JSONArray.fromObject(results);
            Iterator iteratorResult = resultArray.iterator();
            while (iteratorResult.hasNext()) {
                JSONObject iteratorJson = (JSONObject) iteratorResult.next();
                System.out.println(iteratorJson.getString("name"));
                System.out.println(iteratorJson.getString("address"));
                System.out.println(iteratorJson.getString("telephone"));
                System.out.println(iteratorJson.getString("uid"));
                JSONObject json_location = (JSONObject) iteratorArray.next();
                JSONObject json_details = (JSONObject) iteratorArray.next();
                String location = json_location.getString("location");
                String details = json_details.getString("detail_info");
            }
        }
    }
next how to write it? Find Great God help !
------ Solution ---------------------------------------- ----
public static void main (String [] args) throws IOException {
JSONArray jsonArray = searchLocation (" Wuhu " ) ;
Iterator iteratorArray = jsonArray.iterator ();
while (iteratorArray.hasNext ()) {
JSONObject json = (JSONObject) iteratorArray.next ();
String results = json.getString ("results");
JSONArray resultArray = JSONArray.fromObject (results);
Iterator iteratorResult = resultArray.iterator ();
while (iteratorResult.hasNext ()) {
JSONObject iteratorJson = (JSONObject) iteratorResult. next ();
System.out.println (iteratorJson.getString ("name" ) ) ;
System.out.println (iteratorJson.getString ("address" ) ) ;
System.out.println (iteratorJson.getString ("telephone" ) ) ;
System.out.println (iteratorJson.getString ("uid" ) ) ;

String location = iteratorJson.getString ("location");
; String details = iteratorJson.getString ("detail_info");
JSONObject location = JSONObject.fromObject (location);
JSONObject details = JSONObject.fromObject (details);
System.out.println (details getString ("environment_rating").);

}
}
}
------ For reference only ------------------------- --------------
location and detail_info and on top of the same resolution, you can resolve part , I think the rest can be resolved .


------ For reference only ---------------------------------- -----

String location = json_location.getString ("location");
String details = json_details.getString ("detail_info");
JSONObject location = JSONObject.fromObject (location);
JSONObject details = JSONObject.fromObject (details);
details getString ("environment_rating");. would say take the money on the line.



JSONObject json string and javaBean is an intermediate object ,
------ For reference only ---------------- -----------------------
way upstairs to try it .
------ For reference only -------------------------------------- -
upstairs or not
------ For reference only ---------------------------- -----------
json if you do not have to turn into a java object such transfer , where you should write the wrong .
------ For reference only -------------------------------------- -
map there how to traverse the map on how to traverse

The beginning of the JSP pages garbled page has been set contentType = "text / html; charset = UTF-8" pageEncoding = "UTF-8"

at the beginning of the JSP page has been set
<% @ page contentType = "text / html; charset = UTF-8"%>
<% @ page language = "java" import = "java.io.File, java.io.FileReader, java.io.BufferedReader, java.io. *" ; pageEncoding = "UTF-8"%>


but IE open at the beginning of the page ( top ) is garbled
( garbled Dbcontent-Length: 433 Date: Sat with a date )

Seek expert to solve


server is Tomcat5.5 jdk 1.5
Before
good today, this question arises server restart
------ Solution ----------------------- ---------------------
in tomcat with a landlord has not set the encoding format ?
URIEncoding = "UTF-8" connectionTimeout = "20000" port = "8088" protocol = "HTTP/1.1" ; redirectPort = "8443" />
------ Solution ---------------------------- ----------------
<% @ page language = "java" import = "java.sql. *, java.util. * "pageEncoding =" UTF-8 "%>
I generally no problem with this , and you try , there may not be a problem head ah
------ Solution ---------------- ----------------------------
can try request, there is a way to set the encoding format specified value !
------ For reference only -------------------------------------- -
added , there is always still the same at the beginning of paragraph garbled
------ For reference only ------------------- --------------------


not the beginning or garbled
------ For reference only ---------------------------- -----------
is HTTP header problem, but why is garbled but also shows up
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie:
Content-Type: text / html; charset = utf-8
Content-Length: 425
Date: Thu, 04 Mar 2010 02:42:41 GMT
------ For reference only ------------- --------------------------


Eclipse configured yet ?

hibernate automatically create table failed

configuration file : class = "org.apache.commons.dbcp.BasicDataSource"
destroy-method = "close">

value = "jdbc: mysql :/ / localhost: 3306/forum characterEncoding = UTF-8?" />




class = "org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"
destroy-method = "destroy">



com.helloweenvsfei.forum.bean.Category
com.helloweenvsfei.forum.bean.Board
com.helloweenvsfei.forum.bean.Thread
com.helloweenvsfei.forum.bean.Person
com.helloweenvsfei.forum.bean.Reply





org.hibernate.dialect.MySQLDialect

true
true
update



error message:
[org.springframework.web.context.ContextLoader] - [ERROR] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/ WEB-INF/classes/applicationContext.xml ]: Invocation of init method failed; nested exception is net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException--> null
possible problems in where?
------ Solution ---------------------------------------- ----
reflecting a proxy object is null . java.lang.reflect.InvocationTargetException--> null
------ Solution ---------------------------- ----------------
this file is not automatically generated bar
------ For reference only ------------ ---------------------------

still do not understand
------ For reference only ---------------------------------------
problem has been resolved. Since the spring of cglib package is automatically imported 1.2 myeclipse conflict , importing 2.0 just fine thank you upstairs

[ REVIEW] newbie question Asked art

 This post last edited by huxiweng on 2013-10-24 14:36:53
Although this is an old saying often talk about, but recently the process of answering questions , and somewhat upset . Your good question to ask the accurate answer to your talent motivated to give you an answer , and so you can solve your problem faster . A lot of people do not know how to ask questions, so I'm going to turn this old post sticky . Take a look .
If you do not have time , at least look at the following chart it:



============================================== ===================================
When asked a technical question, how can you get the answer ? It depends on the difficulty dug answer the same question depends on your approach. This guide is designed to help you improve your skills to ask questions to get the answers you want most ......

do not want to cover up some people's contempt for this - they do not want to think, or not completed before asking what they should do . This person will murder the time - they only wish to obtain a copy , never pay, they waste our time , and we can put this time in a more interesting question to answer , or more worthy people. We call such people "losers" ( for historical reasons we sometimes spell it as "lusers").
Before
questions (Before You Ask)

before proposing technical issues via e-mail , newsgroups or chat rooms, check that you have not done :
1. entire manual, try to find the answers themselves .
2. searching for answers in the FAQ ( The FAQ is a well maintained all-inclusive :) .
3. in online search ( personally recommend google ~ ~ ~).
4. around you at this game to a friend inquire .

When you ask questions , we must first explain before what you did ; This will help build your image: You're not being a lazy beggars who do not want to waste people's time . If the questioner learn something from the answers , we are more willing to answer his questions .

thoughtful thinking, ready for your questions , hasty answer questions only get sloppy , or simply can not get any answers . The more exhibits before asking for help to pay for efforts to solve the problem , the more you can get substantial help .

careful not asking the wrong question .

On the other hand , show that you are willing to do something in the process of searching for answers , is a very good start. " Who can give a hint ? " " I'm missing this example of what ? " And " what should I check ? " Than " Please stick out the exact process " easier to get a reply. Just because you look someone pointing in the right direction , you have the ability and determination to finish it .

how questions (When You Ask)

carefully chosen forum

carefully selected questions occasions. If , as described below , and you are likely to be ignored or be seen as losers :
1. irrelevant to the forum posted in your question
2 explore advanced techniques forum posting very elementary question ; vice versa
3. in too many different newsgroups cross- posted

terminology appropriate, correct grammar , spelling and correct

We found from experience , careless writers usually sloppy thinkers ( I 'm pretty sure ) .

careless answer those questions very worth it, we would rather time consuming elsewhere.

correct spelling , punctuation and capitalization is very important.

More generally , if your question is written like a semi-literate , you are likely to be ignored.

If you are using non- native speakers of the forum to ask questions, you can commit a small mistake on the point of spelling and grammar - but never on the sloppy thinking (yes, we can understand the difference between the two )

meaning rich use to describe the exact title

mailing list or newsgroup , about 50 words or less subject heading is to seize the golden opportunity to the attention of senior experts . not use chatter " help " ( let alone "help ah ! ! ! ! ! " This distasteful words ) to waste this opportunity. Do not use your level of paranoia painful to impress us , do not use spaces instead of describing the problem , even if it is a very brief description .

stupid question:

help ah ! My laptop machine is not properly show !

Smart:

XFree86 4.1 mouse cursor deformation of graphics chips Fooware MV1005 .

If you ask questions in reply , remember to modify the contents of the title , indicating that there is a problem . One looks like "Re: Test" or "Re: New bug" problem is difficult enough attention . In addition , references and delete the contents of the foregoing, for new readers to leave clues.

accurate description , the amount of information

1. carefully clear description of symptoms.
2. providing environmental problems occur ( machine configuration , operating system , applications, and anything else ) .
3. instructions before asking you how to study and understand the problem.
4. instructions before asking you what steps to take to solve it .
5. listed done anything recently that may affect hardware and software changes .

Simon Tatham has written an article entitled " How to effectively report Bug" excellent essay. Strongly recommend that you read it .

if not more

you need to provide accurate and effective information . This does not require you to simply put a ton of extracted data is completely wrong code or dump to your question in . If you have a large and complex test conditions , try to cut it as small as possible .

usefulness of doing at least three points. First, to show you have made efforts to simplify the problem, which allows you to increase the chance of getting the answer ; Second , simplify the problem so that you get a useful answer to the increased chance ; Third, refine your bug reporting process, perhaps you will be able to identify the problem or make corrections.

stupid question:

I encountered again and again SIG11 errors in the kernel compilation, I suspect a ride on the Main Board of the fly line to go online , and

how this situation should check the best ?

Smart:

I made ​​a K6/233 system , the motherboard is FIC-PA2007 (VIA Apollo VP2 chipset ), 256MB
Corsair PC133 SDRAM, frequently produced in the kernel compile SIG11 errors from the boot after 20 minutes there is such a case , never happened before turning over within 20 minutes . Restart did not use, but can shut down a night job for 20 minutes. All memory is replaced , to no avail . Typical compile relevant part as follows ... record .

symptoms listed in chronological order

to identify problems most helpful clue is often a series of operations before the problem occurred , so your description should include steps, as well as reaction computer until problems .

If your description is very long ( more than four paragraphs ) , outlined at the beginning of the problem will be helpful , then detailed chronological order. This will let people know what to look for in your description .

understand what you want to ask

rambling question time almost endless black hole . Most people give you a useful answer is also the busiest people ( because they are busy most of the work yourself ) . Such people are unrestrained time black hole is not too cold , so it can be said that they ask questions of rambling little cold. If you clearly stated what respondents do ( providing advice , sending a piece of code , check your patch or anything else ) , you are most likely to get useful answers. This will set an upper limit of time and effort , to facilitate respondents focus to help you , it is very adds.

solve your problem , the less time needed , the more expert mouth pulled out from a busy answers . Therefore , the structure of the optimization problem to minimize the time it needs to resolve the experts , there will be a great help - this is usually differ and simplify the problem . Therefore , ask, " I want a better understanding of X, can give some tips? " Is usually higher than asked, " Can you explain X do ? " Better . If your code does not work , ask what is wrong with it , than ask someone for you to modify much wiser.

Do not ask yourself questions that should be addressed

These problems have you to get, you'll learn something . You can ask for a hint , but do not ask for a complete solution .

remove meaningless questions

do not use meaningless words ending questions , such as " someone help me? " or " have the answer? ."

First : If the problem you describe is not very appropriate, ask it is superfluous. Second : Because this is superfluous to ask , others will irks you - and usually answer with the correct logic to show their contempt for example: "Yes, someone can help you ," or " No, not the answer ."

humble absolutely no harm , and often helps a lot

polite, multi-use " please" and " thank first road points ." Let everyone know that you spend time on their obligation to help grateful.

However, if you have a lot of problems can not be solved , courtesy will increase your chances of getting a useful answer .

After problem solving , plus a brief description

After the problem is resolved, to all the people who helped you to send a note to let them know what the problem is resolved , and once again thank them . If the problem is caused widespread concern in the newsgroup or mailing list , there should be affixed to a supplement . Supplement do not have a long or very deep ; simple " hello , turned out to be a problem with the network cable thank you - Bill!" Stronger than say nothing . In fact, the conclusion is really very technical content unless otherwise lovely brief summary better than the full-length papers . Description of the problem is how to solve , but no need to repeat the process of solving the problem again .

polite and feedback information in addition to outside , this supplement helps others on the mailing list / newsgroup / forum search for you have had a complete solution to help , which may also be useful for them .

Finally ( at least ? ) , this supplement helps all who provided assistance derive satisfaction. For those feeling a mentor or expert you ask them for help , it is very important. Protracted problem will be frustrating ; good turn deserves another , to satisfy their cravings, you will taste the sweetness when posting new questions in the next .

finally solve the problem over to knot paste right ?


------ Solution ------------------------------------ --------
support +1
------ Solution ------------------------ --------------------

http://bbs.csdn.net/topics/360018663 # r_71325270
- ----- Solution --------------------------------------------

thank inspection tips ! Put that figure to move over !  
move , however. . CSDN too 2 , and post pictures but also the first network to upload !
user experience that is not considered ~


------ Solution ------------------------------------ --------
+1
------ Solution - -------------------------------------------

thank inspection tips ! Put that figure to move over !          
move , however. . CSDN too 2 , and post pictures but also the first network to upload !   
user experience that is not considered ~   
  
 
album pictures now even have to die img.my.csdn.net ... img. bbs . csdn.net this
(· ิ ω · ิ)
------ Solution ----------------------- ---------------------
very very good. .
------ Solution ---------------------------------------- ----
to bear stickers +1
------ Solution - -------------------------------------------
ah very good things learned
------ Solution --------------------------------- -----------
really taught ah.
------ Solution ---------------------------------------- ----
leaving. . . .
------ Solution ---------------------------------------- ----
that good . Learn !
------ Solution ---------------------------------------- ----
I came to pick up points to the urgency it .
------ Solution ---------------------------------------- ----
this is not a Linux mailing list documentation what "question of the art "
------ Solution ------------------- -------------------------
when asked a technical question, how can you get the answer ? It depends on the difficulty dug answer the same question depends on your approach. This guide is designed to help you improve your skills to ask questions to get the answers you want most ......
------ Solution -------------------- ------------------------

nice post .
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
looking giddy . Hello rationale winded
------ Solution ------------------------------------- -------
that good . Learn !
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------

----- - Solution --------------------------------------------
bit elite, I did not read English, have been very troubled . Want to give you the expert advice . So I just bought a portion of the BlackBerry smartphone , on how many other sites to download software and games can not be installed after the download is complete always prompt file can not be opened . Please elite pointing, the simpler the better , thank
------ Solution --------------------------- -----------------
, very helpful for me to learn in silence .
------ Solution ------- -------------------------------------
come and take points it! !
------ Solution ---------------------------------------- ----
pick of me. . .
------ Solution ---------------------------------------- ----
finally solve the problem over to knot paste right ?
------ Solution - -------------------------------------------

------ Solution ----- ---------------------------------------
learn
------ Solution - -------------------------------------------
I know because BAIDU to stop the account , and in the online search process, see the familiar CSDN, so try holding the idea to ask questions, issues, although it is not technology , but still get the moderator 's answer , see this post written by moderator the more I feel the need to own learning , a lot of thinking. At the same time feel more like fun . Thank you for helping moderator here .
------ Solution ---------------------------------------- ----
good ah. . .
------ Solution ---------------------------------------- ----
+1 support learn
------ Solution --------------------------------------------
learn
------ Solution - -------------------------------------------

------ Solution ----- ---------------------------------------
support, especially do not want you directly to the code . Thinking and give yourself space. Give some important segments like.
------ Solution ---------------------------------------- ----
support is very good, save one
------ Solution -------------------------- ------------------
landlord very detailed summary is in place , amazing!
------ Solution ---------------------------------------- ----
novice learning over the next
------ Solution - -------------------------------------------
Java forum 's death paste too much, consider whether the moderator dealt with as part of it , so do not pick stickers, blow everyone replies enthusiasm.
------ Solution - -------------------------------------------
question really is how art, taught , like this one !
------ Solution ---------------------------------------- ----
newcomers learn here.
------ Solution ---------------------------------------- ----
newcomers , which under the learned
------ For reference only ------------------------- --------------
edition I occasionally get to the actual posts analogy , not the person , please understand
------ For comrades reference only ---------------------------------------
support +1  
thanks for the support !

------ For reference only ---------------------------------------

thank inspection Tip ! Put that figure to move over !
------ For reference only -------------------------------------- -

thank inspection tips ! Put that figure to move over !          
move , however. . CSDN too 2 , and post pictures but also the first network to upload !   
user experience that is not considered ~   
  
 
This reaction can and administrators . I downloaded and uploaded
------ For reference only ---------------------------------------
  The reply was deleted administrator at 2013-10-25 09:16:11

------ For reference only ---------------------------------- -----
Well, the first time examples, do not cut out the id of the post directly cut headings :

this senseless , do not use the title , the first you do not express what your problem is , and this "help" or something , people feel that is not the problem through direct throw up thinking of ! The result is that nobody or very few people to see your post, and you will get our recommendations.
change the name of a good point , why not ?

good title : hibernate.cfg.xml configuration items in doubt about hibernate.connection.url rotten
title : help ah ! !

------ For reference only ---------------------------------- -----
  The reply was deleted administrator at 2013-11-12 08:58:28

------ For reference only ---------------------------------- -----

we will regularly Results posted manage :)
------ For reference only -------------- -------------------------
long , but taught the
------ For reference only ---------------------------------------
  The reply was deleted administrator at 2013-11-23 09:26:39

Consult request.getSession () getServletContext () getRealPath ("/");.. This sentence is the server path to get it?

Getting Started , thank you advise ~ !
------ Solution ---------------------------------------- ----

so I went to ask if this is the path to save the file saved to a file on the server yet ?  
yes.
------ For reference only -------------------------------------- -
this method seems to have been abandoned in the windows is so , linux hard to say.
------ For reference only -------------------------------------- -
returns the absolute path to the root directory of the virtual directory.
------ For reference only -------------------------------------- -
get is what you tomcat project root path
------ For reference only webapps under ---------------------- -----------------
you print it out do not know, this is the return path works include letters , absolute path.
------ For reference only -------------------------------------- -

so I went to ask if this is the path to save the file saved to a file on the server yet ?
------ For reference only -------------------------------------- -

so I went to ask if this is the path to save the file saved to a file on the server yet ?          
yes.  
Thank you ~ ~ ~

Beginner , if handled ajax and servlet relations

beginner java using ajax request data receiving servlet, then call the servlet class so I equivalent when a multi- layer concept.

functions to achieve , but now there is a problem add edit delete it so requests every request I have to build a new servlet

everyone is doing it? Simplify it? I mean without using spring struts framework and so on .


Of course I do not want to get parameter to distinguish the way requse.getParameter execution method . .

is how we deal with. beginner on coaching
------ Solution --------------------------------- -----------
should be able to use the same servlet, and then distribute the landlord can investigate it
------ Solution ----------- ---------------------------------
same servlet, pass the value when the method name passed to the background doing compared to determine which one to call .
For example : url:? xxxx / xxx m = method_name, get the value of m in the background , and compare your method names .
------ Solution ---------------------------------------- ----
from the top two floors. . Some of it you can operate inside wrote method can be invoked inside dopost, doget, the second floor of the method used to call , or if esle switch to call the
------ Solution --- more -----------------------------------------
approach.
1. you can be equipped with multiple servlet (@ WebServlet ({servlet1, servlet2 ...})) annotation configuration is also very convenient.
2 you pass a parameter when accessing the servlet , such as :.? xxxx.do method = add, and then you get your servlet by this parameter , then the request is distributed on OK , a simple code to write about , you can read on line:
doPost (request, response) {
String method = request.getParameter ("method");
if (method.equals "add") {
this.add (request, response);
}
if (method.equals "delete") {
this.delete (request, response);
}
}

private void add (request, response) {
....
}

private void delete (request, response) {
....
}
------ Solution ----------------------------------- ---------
4 floor switch I think it is better
------ Solution -------------------- ------------------------


String uri = request.getRequestURI ();
String action = uri.substring (uri.lastIndexOf ("/"), uri.lastIndexOf () ".");
if (action.equals ("/ add")) {
block ......
} else if (action.equals ("/ edit")) {
block ......
} else if (action.equals ("/ delete")) {
block ......
}

------ For reference only ---------------------------------- -----
Oh, I do not want to use a method of regional services parameters do