Академический Документы
Профессиональный Документы
Культура Документы
Tomcat's Directories
Take a quick look at the Tomcat installed directory. It contains the following subdirectories:
bin : contains the binaries; and startup script ( startup.bat for Windows and
startup.sh for Unixes and Mac OS X), shutdown script ( shutdown.bat for Windows
and shutdown.sh for Unix and Mac OS X), and other binaries and scripts.
lib : contains the Tomcat's system-wide JAR files, accessible by all webapps. You
could also place external JAR file (such as MySQL JDBC Driver) here.
logs : contains Tomcat's log files. You may need to check for error messages
here.
webapps : contains the webapps to be deployed. You can also place the WAR
(Webapp Archive) file for deployment here.
ERROR
Server Tomcat v8.0 Server at localhost failed to start.
Solution 1 : There is a problem with your xml file so remove all the mappings
Solution 2 : To resolve this issue, you have to delete the .snap file located in the directory :
<workspace-directory>\.metadata\.plugins\org.eclipse.core.resources
After deleting this file, you could start Eclipse with no problem
Solutio
n
3:
To resolve this issue you have to delete tmp folder in the following directory
<workspace-directory>\.metadata\.plugins\org.eclipse.wst.server.core
If there is any problem on deleting this folder then restart your eclipse then again
delete that folder.
Solution 4 : Check the @WevServlet annotation
Solution 5 : **1. Open the Servers Tab from Windows>Show View>Servers menu
1.
2.
3.
4.
Select the Apache Tomcat v7.0 server and remove it. This will remove the Tomcat
server configuration. This is where many people do mistake they remove the server
but do not remove the Runtime environment.
5.
6.
From the screen below, choose Apache Tomcat v7.0 server and click on next button:
7.
8.
Click on Next and choose which project you would like to deploy:
9.
10.
Now launch your server. This will fix your Server timeout or any issues with old
server configuration. This solution can also be used to fix port update not being taking
place issues.**
Several ports (8005, 9999, 8009) required by Tomcat v8.0 Server at localhost are
already in use.
Solution 1 :
208down
vote
accepted
You've another instance of Tomcat already running. You can confirm this by
going to http://localhost:8080 in your webbrowser and check if you get the
Tomcat default home page or a Tomcat-specific 404 error page. Both are
equally valid evidence that Tomcat runs fine; if it didn't, then you would have
gotten a browser specific HTTP connection timeout error message.
You need to shutdown it. Go to /bin subfolder of the Tomcat installation folder
and execute the shutdown.bat (Windows) or shutdown.sh (Unix) script. If in
vain, close Eclipse and then open the task manager and kill all java and/or
javaw processes. Or if you actually installed it as a Windows service for some
reason (this is namely intented for production and is unhelpful when you're just
developing), open the services manager (Start > Run > services.msc) and stop
the Tomcat service. If necessary, uninstall the Windows service altogether. For
development, just the ZIP file is sufficient.
You need to add the Servlet API to your classpath. In Tomcat 6.0, this is in a JAR called
servlet-api.jar in Tomcat's lib folder. You can either add a reference to that JAR to the
project's classpath, or put a copy of the JAR in your Eclipse project and add it to the
classpath from there.
If you want to leave the JAR in Tomcat's lib folder:
=a=a=a=a=a==a=a==a=a=a=a===a=a=a=a=a=a=a==a=a=a=a=a=
Formanyandroidapplicationsitisessentialthatapp needstoconnecttointernetandmakesomeHTTP
requests.StepsbelowexplainaboutmakingsimpleHTTPRequestsinandroid.
Create your HttpClient and HttpPost objects to execute the POST request. The address is a
String object representing your POST's destination, such as a Servelt,JSP page or PHP
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(address);
Setting POST data. A list of NameValuePairs are created and set as the HttpPost's entity.Ensure to
catch the UnsupportedEncodingException thrown by HttpPost.setEntity().
List<NameValuePair> pairs = new ArrayList<NameValuePair>();
pairs.add(new BasicNameValuePair("key1", "value1"));
post.setEntity(new UrlEncodedFormEntity(pairs));
Execute the POST request. This returns an HttpResponse object, whose data can be extracted and
parsed. Ensure to catch the ClientProtocolException and IOException thrown.
HttpResponse response = client.execute(post);.
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(url);
Do not forget to declare Internet permissions in the manifest by adding the following line to
AndroidManifest.xml. This allows your application to use any Internet connections.
AsyncTask:
AsyncTaskisanabstractclassprovidedbyAndroidwhichhelpsustousetheUIthreadproperly.
Thisclassallowsustoperformlong/backgroundoperationsandshowitsresultontheUIthreadwithout
havingtomanipulatethreads
WhentouseAsyncTask?
Androidimplementssinglethreadmodelandwheneveranandroidapplicationislaunched,athreadis
created.Assumingwearedoingnetworkoperationonabuttonclickinourapplication.Onbuttonclicka
requestwouldbemadetotheserverandresponsewillbeawaited.Duetosinglethreadmodelofandroid,till
thetimeresponseisawaitedourscreenisnonresponsive.Soweshouldavoidperforminglongrunning
operationsontheUIthread.Thisincludesfileandnetworkaccess.AsyncTask which
runs separate thread in background .Any meaningful GUI application needs to
employ multiple threads, otherwise it is very likely to lock while doing any I/O
operations - leaving bad impression on the user. Same is true for Android apps. In
fact, android framework prompts user to close the app if it doesn't respond in 10
seconds or so. So it's absolutely essential to perform any task - that has even a
remote possibility of taking a bit longer - in a background thread.
Toovercomethiswecancreatenewthreadandimplementrunmethodtoperformthisnetworkcall,so
UIremainsresponsive.
ButsinceAndroidfollowssinglethreadmodelandAndroidUItoolkitisnotthreadsafe,soifthereisa
needtomakesomechangetotheUIbasedontheresultoftheoperationperformed,thenthisapproachmay
leadsomeissues.
AndroidframeworkhasgivenaverygoodpatternwhichisenvelopedintoAsyncTask.
Note:AsyncTaskshouldideallybeusedforoperationsthattakefewseconds.Sometaskskeepthethread
runningforlongtimesointhatcaseitisrecommendedtousejava.util.concurrentpackagesuchasExecutor,
ThreadPoolExecutorandFutureTask.
AsyncTaskhasfoursteps:Whenanasynchronoustaskisexecuted,thetaskgoesthrough4steps:
onPreExecute(),invokedontheUIthreadbeforethetaskisexecuted.Thisstepisnormallyusedto
setupthetask,forinstancebyshowingaprogressbarintheuserinterface.
doInBackground(Params...),invokedonthebackgroundthreadimmediatelyafteronPreExecute()
finishesexecuting.Thisstepisusedtoperformbackgroundcomputationthatcantakealongtime.
Theparametersoftheasynchronoustaskarepassedtothisstep.Theresultofthecomputation
must be returnedbythis step andwill be passed backto the last step. This step can also use
publishProgress(Progress...)topublishoneormoreunitsofprogress.Thesevaluesarepublished
ontheUIthread,intheonProgressUpdate(Progress...)step.
onProgressUpdate(Progress...), invoked on the UI thread after a call to
publishProgress(Progress...). The timing of the execution is undefined. This method is used to
display any form of progress in the user interface while the background computation is still
executing.Forinstance,itcanbeusedtoanimateaprogressbarorshowlogsinatextfield.
onPostExecute(Result),invokedontheUIthreadafterthebackgroundcomputationfinishes.The
resultofthebackgroundcomputationispassedtothisstepasaparameter.
Cancellingatask,Ataskcanbecancelledatanytimebyinvokingcancel(boolean).Invokingthis
methodwillcausesubsequentcallstoisCancelled()toreturntrue.Afterinvokingthismethod,
onCancelled(Object), instead of onPostExecute(Object) will be invoked after
doInBackground(Object[])returns.Toensurethatataskiscancelledasquicklyaspossible,you
shouldalwayscheckthereturnvalueofisCancelled()periodicallyfromdoInBackground(Object[]),
ifpossible(insidealoopforinstance.).
Threadingrules:Thereareafewthreadingrulesthatmustbefollowedforthisclasstowork
properly:TheAsyncTaskclassmustbeloadedontheUIthread.Thisisdoneautomaticallyasof
JELLY_BEAN.
ThetaskinstancemustbecreatedontheUIthread.
public void onClick(View view) {
GetXMLTask task = new GetXMLTask();
task.execute(new String[] { URL });
}
execute(Params...)mustbeinvokedontheUIthread.
DonotcallonPreExecute(),onPostExecute(Result),doInBackground(Params...),
onProgressUpdate(Progress...)manually.
Thetaskcanbeexecutedonlyonce(anexceptionwillbethrownifasecondexecutionisattempted.)
Memoryobservability
AsyncTaskguaranteesthatallcallbackcallsaresynchronizedinsuchawaythatthefollowingoperations
aresafewithoutexplicitsynchronizations.
SetmemberfieldsintheconstructororonPreExecute(),andrefertothemindoInBackground(Params...).
SetmemberfieldsindoInBackground(Params...),andrefertotheminonProgressUpdate(Progress...)and
onPostExecute(Result).
SOURCE : http://navinsandroidtutorial.blogspot.in/2013/05/android-networking-postdata-to-servlet.html
An asynchronous task is defined by 3 generic types, called Params, Progress and Result,
and 4 steps, called onPreExecute, doInBackground, onProgressUpdate and onPostExecute.
AsyncTask's generic types :
The three types used by an asynchronous task are the following:
Params, the type of the parameters sent to the task upon execution.
Progress, the type of the progress units published during the background computation.
Result, the type of the result of the background computation.