问:
How to manage multiple notification in service using alarm manager
I have number of toggles like, 2 minute, 4 minute and 24 hours. if user select any one, the service will be start and set repeat time in alarm manager, the Notification will showing for particular selected time.

Now the problem is i want to show the number of title like for 2 minute reminder, 4 minute reminder and 24 hours reminder. how to manage these all the titles in local notification service and manage click event.

My code is How to keep service alive when remove app from stack

Please suggest to find solution.

答:
In the pendingIntent for your AlarmManager you can put extras and you can pass title to your MyReceiver activity like following.</p>

```<code>Intent myIntent = new Intent(NotificationDemo.this, MyReceiver.class);
myIntent.putExtra("title","2 minutes");
                pendingIntent =
PendingIntent.getBroadcast(NotificationDemo.this, 0, myIntent, 0);
</code>```

Body:
In the pendingIntent for your AlarmManager you can put extras and you can pass title to your MyReceiver activity like following.

Intent myIntent = new Intent(NotificationDemo.this, MyReceiver.class);
myIntent.putExtra("title","2 minutes");
                pendingIntent =
PendingIntent.getBroadcast(NotificationDemo.this, 0, myIntent, 0);


来源: stackexchange

问:
Aliases in .bash_profile not working properly
I have been trying to alter the .bash_profile that is in my root directory, but have been running into some problems. I am on OS X, Yosemite, on a Macbook Pro. As I understand it, the .bash_profile file contains the script that is called automatically whenever the Terminal app is opened and the bash shell starts.
This is what I currently have written in that file:

```<code>PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH
</code>```

This works perfectly fine. However, I want to add an alias (right underneath the above two lines) as follows:

```<code>alias test='cd ..'
</code>```

However, when I save this and start up the Terminal, I get the following message:

```<code>-bash: alias: ..": not found
</code>```

Replacing the single quotes with double quotes doesn't help, nor does taking them away altogether. Curiously however, the following alias works:

```<code>alias c=clear
</code>```

When I type c into the terminal, it clear the screen, as you would expect. However, if I instead entered this line with quotes in the bash profile as:

```<code>alias c='clear'
</code>```

Then I will get the following whenever I enter c into the Terminal:

```<code>-bash: 'clear': command not found
</code>```

Note that I do not get an error message on startup for this alias.

What am I doing wrong? Is there a setting I need to change somewhere to get aliases to work properly? I have seen previous examples of aliases and they simply do not work for me.

答: For me, it didn't work in the same terminal. I had to open a new one to get it work.</p>

ContentLicense: CC BY-SA 3.0

Body:
I have been trying to alter the .bash_profile that is in my root directory, but have been running into some problems. I am on OS X, Yosemite, on a Macbook Pro. As I understand it, the .bash_profile file contains the script that is called automatically whenever the Terminal app is opened and the bash shell starts.
This is what I currently have written in that file:

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

This works perfectly fine. However, I want to add an alias (right underneath the above two lines) as follows:

alias test='cd ..'

However, when I save this and start up the Terminal, I get the following message:

-bash: alias: ..": not found

Replacing the single quotes with double quotes doesn't help, nor does taking them away altogether. Curiously however, the following alias works:

alias c=clear

When I type c into the terminal, it clear the screen, as you would expect. However, if I instead entered this line with quotes in the bash profile as:

alias c='clear'

Then I will get the following whenever I enter c into the Terminal:

-bash: 'clear': command not found

Note that I do not get an error message on startup for this alias.

What am I doing wrong? Is there a setting I need to change somewhere to get aliases to work properly? I have seen previous examples of aliases and they simply do not work for me.


问:
*Error* RecycleView into another fragment
Hi guys thank for  in adv,

Originally is suppose to works like when i click any item in the recyclerView would bring me to another fragment that display the details.

whenever I click on the item in recyclerView would crash immediately. So i thinking was it my onClick method set wrong or whatever.

/**
 * pending_Fragment
 */

public class pending_fragment extends Fragment implements
   RecyclerViewAdapter.ItemClickCallBack, View.OnClickListener{

```<code>private static final String BUNDLE_EXTRAS = "BUNDLE_EXTRAS";
private static final String EXTRA_SUBMITDATE = "EXTRA_SUBMITDATE";
private static final String EXTRA_DERIVE = "EXTRA_DERIVE";
private static final String EXTRA_STARTEND = "EXTRA_STARTEND";
private static final String EXTRA_STATUS = "EXTRA_STATUS";

private RecyclerView recView;
private RecyclerViewAdapter adapter;
private List<ListItem> listData;
private TextView textViewView;

private String jsonString = "";

public pending_fragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    final String url = "http://52.187.24.214/medical_certificates/";
    new AsyncHTTPTask().execute(url);

    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_pending_fragment, container, false);

    recView = (RecyclerView) v.findViewById(R.id.rec_list);
    adapter = new RecyclerViewAdapter(listData, getActivity());

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recView.setLayoutManager(layoutManager);
    adapter.setItemClickCallBack(this);

    return v;
}

@Override
public void onClick(View v) {
}

@Override
public void onItemClick(int p) {
    Intent i = new Intent(getActivity(), detailActivity.class);
    ListItem item = (ListItem) listData.get(p);
    Bundle extras = new Bundle();
    extras.putString(EXTRA_SUBMITDATE, "asd");
    extras.putString(EXTRA_DERIVE, "asdsad");
    extras.putString(EXTRA_STARTEND, "asdsad");
    extras.putString(EXTRA_STATUS, "asdsad");
    i.putExtra(BUNDLE_EXTRAS, extras);

    startActivity(i);
}

public class AsyncHTTPTask extends AsyncTask<String, Void, Integer>{

    @Override
    protected Integer doInBackground(String... params){
        Integer result = 0;
        HttpURLConnection urlConnection;
        try{
            URL url = new URL(params[0]);
            urlConnection = (HttpURLConnection) url.openConnection();
            int statusCode = urlConnection.getResponseCode();

            // 200 represents HTTP OK
            if (statusCode == 200){
                BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = r.readLine()) != null) {
                    response.append(line);
                }
                jsonString = response.toString();
                parseResult();
                result = 1; // Successful
            } else {
                result = 0; //"Failed to fetch data!";
            }
        } catch (Exception e) {
            Log.d("Exception Caught", e.getLocalizedMessage());
        }
        return result; //"Failed to fetch data!";
        }
    @Override
    protected void onPostExecute(Integer result) {

        super.onPostExecute(result);

        if (result == 1) {
            adapter = new RecyclerViewAdapter(listData, getActivity());
            //Setting the adapter
            recView.setAdapter(adapter);
        } else {
            Toast.makeText(getActivity(), "Failed to fetch data!", Toast.LENGTH_SHORT).show();
        }
    }

    //This method will parse the RAW data downloaded from the server
    private void parseResult() {

        try {

            JSONObject jsonObj = new JSONObject(jsonString);
            JSONArray wholeData = jsonObj.getJSONArray("data");
            listData = new ArrayList<>();

            for (int i = 0; i < wholeData.length(); i++) {
                JSONObject parentData = wholeData.getJSONObject(i);
                JSONObject childData = parentData.getJSONObject("attributes");
                ListItem item = new ListItem();
                item.setSubmissionDate(childData.getString("created-at"));
                item.setStartDate(childData.getString("start-date"));
                item.setStatus(childData.getString("status"));
                listData.add(item);

                //Log.e("Event Name", c.getString("eventName"));
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}
</code>```

}

/**
 * RecylerViewAdapter
 */

```<code>public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
private List<ListItem> listData;
private LayoutInflater inflater;

//Interface, a communication alternative that doesn't hold memory
private ItemClickCallBack itemClickCallBack;

//Creates a layout inflater from the context
public RecyclerViewAdapter(List<ListItem> listData, Context c){
    this.inflater = LayoutInflater.from(c);
    this.listData = listData;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = inflater.inflate(R.layout.list_item, parent, false);

    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    ListItem item = listData.get(position);
    holder.submissionDate.setText(item.getSubmissionDate());
    holder.startDate.setText(item.getStartDate());
    holder.status.setText(item.getStatus());
}

@Override
public int getItemCount() {
    return listData.size();
}

public void setItemClickCallBack(final ItemClickCallBack itemClickCallBack){
    this.itemClickCallBack = itemClickCallBack;
}

public interface ItemClickCallBack {
    //if user clicks container then react accordingly
    void onItemClick(int p);
}

//updater
public void setListData(ArrayList<ListItem> exerciseList) {
    this.listData.clear();
    this.listData.addAll(exerciseList);
}

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    private TextView submissionDate;
    private TextView startDate;
    private TextView endDate;
    private TextView status;
    private TextView reject_reason;
    private View container;

    public ViewHolder(View itemView) {
        super(itemView);

        submissionDate = (TextView)itemView.findViewById(R.id.lbl_item_text);
        startDate = (TextView)itemView.findViewById(R.id.lbl_from_date_to_date);
        status = (TextView)itemView.findViewById(R.id.lbl_status);
        container = itemView.findViewById(R.id.cont_item_root);
        container.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        //Checks ID
        if (v.getId()== R.id.cont_item_root) {
            //Gets the position of item that was clicked
            itemClickCallBack.onItemClick((getAdapterPosition()));
        }
    }
}
</code>```

}

FATAL EXCEPTION: main
                                                                                Process: com.example.kaiying.mc_submission, PID: 22831
                                                                                java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.kaiying.mc_submission.student.adapter.RecyclerViewAdapter$ItemClickCallBack.onItemClick(java.lang.String)' on a null object reference

答:
Update the onPostExecute() like below

```<code>@Override
protected void onPostExecute(Integer result) {

    super.onPostExecute(result);

    if (result == 1) {
        adapter = new RecyclerViewAdapter(listData, getActivity());
        //Setting the adapter
        adapter.setItemClickCallBack(pending_fragment.this);
        recView.setAdapter(adapter);
    } else {
        Toast.makeText(getActivity(), "Failed to fetch data!", Toast.LENGTH_SHORT).show();
    }
}
</code>```

Body:
Hi guys thank for  in adv,

Originally is suppose to works like when i click any item in the recyclerView would bring me to another fragment that display the details.

whenever I click on the item in recyclerView would crash immediately. So i thinking was it my onClick method set wrong or whatever.

/**
 * pending_Fragment
 */

public class pending_fragment extends Fragment implements
   RecyclerViewAdapter.ItemClickCallBack, View.OnClickListener{

private static final String BUNDLE_EXTRAS = "BUNDLE_EXTRAS";
private static final String EXTRA_SUBMITDATE = "EXTRA_SUBMITDATE";
private static final String EXTRA_DERIVE = "EXTRA_DERIVE";
private static final String EXTRA_STARTEND = "EXTRA_STARTEND";
private static final String EXTRA_STATUS = "EXTRA_STATUS";

private RecyclerView recView;
private RecyclerViewAdapter adapter;
private List<ListItem> listData;
private TextView textViewView;

private String jsonString = "";

public pending_fragment() {
    // Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    final String url = "http://52.187.24.214/medical_certificates/";
    new AsyncHTTPTask().execute(url);

    // Inflate the layout for this fragment
    View v = inflater.inflate(R.layout.fragment_pending_fragment, container, false);

    recView = (RecyclerView) v.findViewById(R.id.rec_list);
    adapter = new RecyclerViewAdapter(listData, getActivity());

    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
    recView.setLayoutManager(layoutManager);
    adapter.setItemClickCallBack(this);

    return v;
}

@Override
public void onClick(View v) {
}

@Override
public void onItemClick(int p) {
    Intent i = new Intent(getActivity(), detailActivity.class);
    ListItem item = (ListItem) listData.get(p);
    Bundle extras = new Bundle();
    extras.putString(EXTRA_SUBMITDATE, "asd");
    extras.putString(EXTRA_DERIVE, "asdsad");
    extras.putString(EXTRA_STARTEND, "asdsad");
    extras.putString(EXTRA_STATUS, "asdsad");
    i.putExtra(BUNDLE_EXTRAS, extras);

    startActivity(i);
}

public class AsyncHTTPTask extends AsyncTask<String, Void, Integer>{

    @Override
    protected Integer doInBackground(String... params){
        Integer result = 0;
        HttpURLConnection urlConnection;
        try{
            URL url = new URL(params[0]);
            urlConnection = (HttpURLConnection) url.openConnection();
            int statusCode = urlConnection.getResponseCode();

            // 200 represents HTTP OK
            if (statusCode == 200){
                BufferedReader r = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
                StringBuilder response = new StringBuilder();
                String line;
                while ((line = r.readLine()) != null) {
                    response.append(line);
                }
                jsonString = response.toString();
                parseResult();
                result = 1; // Successful
            } else {
                result = 0; //"Failed to fetch data!";
            }
        } catch (Exception e) {
            Log.d("Exception Caught", e.getLocalizedMessage());
        }
        return result; //"Failed to fetch data!";
        }
    @Override
    protected void onPostExecute(Integer result) {

        super.onPostExecute(result);

        if (result == 1) {
            adapter = new RecyclerViewAdapter(listData, getActivity());
            //Setting the adapter
            recView.setAdapter(adapter);
        } else {
            Toast.makeText(getActivity(), "Failed to fetch data!", Toast.LENGTH_SHORT).show();
        }
    }

    //This method will parse the RAW data downloaded from the server
    private void parseResult() {

        try {

            JSONObject jsonObj = new JSONObject(jsonString);
            JSONArray wholeData = jsonObj.getJSONArray("data");
            listData = new ArrayList<>();

            for (int i = 0; i < wholeData.length(); i++) {
                JSONObject parentData = wholeData.getJSONObject(i);
                JSONObject childData = parentData.getJSONObject("attributes");
                ListItem item = new ListItem();
                item.setSubmissionDate(childData.getString("created-at"));
                item.setStartDate(childData.getString("start-date"));
                item.setStatus(childData.getString("status"));
                listData.add(item);

                //Log.e("Event Name", c.getString("eventName"));
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
    }
}

}

/**
 * RecylerViewAdapter
 */

public class RecyclerViewAdapter extends
RecyclerView.Adapter<RecyclerViewAdapter.ViewHolder> {
private List<ListItem> listData;
private LayoutInflater inflater;

//Interface, a communication alternative that doesn't hold memory
private ItemClickCallBack itemClickCallBack;

//Creates a layout inflater from the context
public RecyclerViewAdapter(List<ListItem> listData, Context c){
    this.inflater = LayoutInflater.from(c);
    this.listData = listData;
}

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = inflater.inflate(R.layout.list_item, parent, false);

    return new ViewHolder(view);
}

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    ListItem item = listData.get(position);
    holder.submissionDate.setText(item.getSubmissionDate());
    holder.startDate.setText(item.getStartDate());
    holder.status.setText(item.getStatus());
}

@Override
public int getItemCount() {
    return listData.size();
}

public void setItemClickCallBack(final ItemClickCallBack itemClickCallBack){
    this.itemClickCallBack = itemClickCallBack;
}

public interface ItemClickCallBack {
    //if user clicks container then react accordingly
    void onItemClick(int p);
}

//updater
public void setListData(ArrayList<ListItem> exerciseList) {
    this.listData.clear();
    this.listData.addAll(exerciseList);
}

public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    private TextView submissionDate;
    private TextView startDate;
    private TextView endDate;
    private TextView status;
    private TextView reject_reason;
    private View container;

    public ViewHolder(View itemView) {
        super(itemView);

        submissionDate = (TextView)itemView.findViewById(R.id.lbl_item_text);
        startDate = (TextView)itemView.findViewById(R.id.lbl_from_date_to_date);
        status = (TextView)itemView.findViewById(R.id.lbl_status);
        container = itemView.findViewById(R.id.cont_item_root);
        container.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        //Checks ID
        if (v.getId()== R.id.cont_item_root) {
            //Gets the position of item that was clicked
            itemClickCallBack.onItemClick((getAdapterPosition()));
        }
    }
}

}

FATAL EXCEPTION: main
                                                                                Process: com.example.kaiying.mc_submission, PID: 22831
                                                                                java.lang.NullPointerException: Attempt to invoke interface method 'void com.example.kaiying.mc_submission.student.adapter.RecyclerViewAdapter$ItemClickCallBack.onItemClick(java.lang.String)' on a null object reference

Body:
Update the onPostExecute() like below

@Override
protected void onPostExecute(Integer result) {

    super.onPostExecute(result);

    if (result == 1) {
        adapter = new RecyclerViewAdapter(listData, getActivity());
        //Setting the adapter
        adapter.setItemClickCallBack(pending_fragment.this);
        recView.setAdapter(adapter);
    } else {
        Toast.makeText(getActivity(), "Failed to fetch data!", Toast.LENGTH_SHORT).show();
    }
}


问:
How to add application name in url bar with jetty server
Hi i have created a maven project with embedded jetty server which is executing fine. After getting jetty server started in eclipse console so to access welcome file (index.jsp) url could be something like this
localhost:8080 is enough but how to add application name into url like below i mention localhost:8080/application_name(FirstAppWithJetty)/

Web.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>FirstAppwithJetty</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  </web-app>
</code>```

pom.xml

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pradeep.maven</groupId>
<artifactId>FirstAppwithJetty</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <finalName>FirstAppwithJetty</finalName>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.11.v20150529</version>
            <configuration>
                <path>/FirstAppwithJetty</path>
                 <stopPort>8080</stopPort>
              <stopKey>jetty:stop</stopKey>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>
</code>```

Exception:

```<code>Error binding monitor port 8080: java.net.BindException: Address already in use: JVM_Bind
[INFO] Started o.e.j.m.p.JettyWebAppContext@157846d4{/,file:/D:/ProjectWithMaven/FirstAppwithJetty/src/main/webapp/,AVAILABLE}{file:/D:/ProjectWithMaven/FirstAppwithJetty/src/main/webapp/}
[WARNING] !RequestLog
[WARNING] FAILED ServerConnector@7a7ca3bd{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] FAILED org.eclipse.jetty.maven.plugin.MavenServerConnector@5a52059c: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] FAILED org.eclipse.jetty.maven.plugin.JettyServer@2bde2e31: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.793 s
[INFO] Finished at: 2017-07-05T14:00:50+05:30
[INFO] Final Memory: 15M/204M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.2.11.v20150529:run (default-cli) on project FirstAppwithJetty: Failure: Address already in use: bind -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
</code>```

答:
Add your appname as finalName in your pom.xml:

```<code><build>
   <finalName>app_name</finalName>
   ....
</build>
</code>```

The result of the build should be a war named app_name.war.
In your case it Looks like:

```<code><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pradeep.maven</groupId>
    <artifactId>FirstAppwithJetty</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0-alpha-1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>FirstAppwithJetty</finalName>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.11.v20150529</version>
                <configuration>
                <path>/FirstAppwithJetty</path>
            </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
</code>```

Body:
Hi i have created a maven project with embedded jetty server which is executing fine. After getting jetty server started in eclipse console so to access welcome file (index.jsp) url could be something like this
localhost:8080 is enough but how to add application name into url like below i mention localhost:8080/application_name(FirstAppWithJetty)/

Web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
  <display-name>FirstAppwithJetty</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  </web-app>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pradeep.maven</groupId>
<artifactId>FirstAppwithJetty</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<dependencies>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>3.0-alpha-1</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <finalName>FirstAppwithJetty</finalName>
    <plugins>
        <plugin>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>9.2.11.v20150529</version>
            <configuration>
                <path>/FirstAppwithJetty</path>
                 <stopPort>8080</stopPort>
              <stopKey>jetty:stop</stopKey>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Exception:

Error binding monitor port 8080: java.net.BindException: Address already in use: JVM_Bind
[INFO] Started o.e.j.m.p.JettyWebAppContext@157846d4{/,file:/D:/ProjectWithMaven/FirstAppwithJetty/src/main/webapp/,AVAILABLE}{file:/D:/ProjectWithMaven/FirstAppwithJetty/src/main/webapp/}
[WARNING] !RequestLog
[WARNING] FAILED ServerConnector@7a7ca3bd{HTTP/1.1}{0.0.0.0:8080}: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] FAILED org.eclipse.jetty.maven.plugin.MavenServerConnector@5a52059c: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[WARNING] FAILED org.eclipse.jetty.maven.plugin.JettyServer@2bde2e31: java.net.BindException: Address already in use: bind
java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:444)
    at sun.nio.ch.Net.bind(Net.java:436)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:214)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
    at org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)
    at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
    at org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.server.Server.doStart(Server.java:366)
    at org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)
    at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:534)
    at org.eclipse.jetty.maven.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:357)
    at org.eclipse.jetty.maven.plugin.JettyRunMojo.execute(JettyRunMojo.java:167)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[INFO] Jetty server exiting.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.793 s
[INFO] Finished at: 2017-07-05T14:00:50+05:30
[INFO] Final Memory: 15M/204M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.jetty:jetty-maven-plugin:9.2.11.v20150529:run (default-cli) on project FirstAppwithJetty: Failure: Address already in use: bind -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Body:
Add your appname as finalName in your pom.xml:

<build>
   <finalName>app_name</finalName>
   ....
</build>

The result of the build should be a war named app_name.war.
In your case it Looks like:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.pradeep.maven</groupId>
    <artifactId>FirstAppwithJetty</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0-alpha-1</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>FirstAppwithJetty</finalName>
        <plugins>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.11.v20150529</version>
                <configuration>
                <path>/FirstAppwithJetty</path>
            </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.2</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>


问:
Application crashes after installing iOS 4.2
I recently installed iOS 4.2 for my iPod after then my application started to crash.

The scenario is: I launch my application wait until it's up and running then hit the iPod home button then launch my application again, my application starts again for seconds then crashes.

my application is a job search engine, so in all of its navigation pages it's communicating with internet server.

I think the problem has to do with applicationDidEnterBackground, applicationWillEnterForeground, or applicationDidBecomeActive methods. I do not have an code in these methods and I do not know if I need to, to prevent the crash.

I do not understand what happens after I hit the home button and my application goes to the background:

will it still be running in the background (because of the multithreading thing in iOS4.2).

Sometimes when I relaunch my application it goes to last page I left in before hitting the home button and sometime it starts from the home page.

I do not understand what's going on, I just want it every time it starts to start in the home page.

I was just about to submit my application to the Apple Store just before I updated to iOS4.2 and the crash starts to happen. I'd really appreciate if someone can help me with this issue that I'm not even able/or know how to debug.

Thanks a lot in advance.
Regards,

答: You can set the Info.plist key ApplicationDoesNotRunOnBackground to make sure the app is completely terminated.

ContentLicense: CC BY-SA 2.5


问:
Function that check if value exists in sql server
Hei,

I need a function in php that checks if a value entered by form is already in database (sql - server -- PDO), and return TRUE or FALSE.

I tried to do this, but I got stuck and didn't found a solution on internet.
could you give me a hint on how to threat the above condition ?

```<code>function check_code($code) {
GLOBAL $handler;
$code = check_input($code);
        try{
      $query2 = $handler -> prepare("SELECT code from stock where code = :code");
      $query2 -> execute(array(
                    ':code' => $code
                    ));
return  >???<
        }
        catch(PDOException $e){
            echo $e -> getMessage();
      }  }
</code>```

答: return something like row_count(result) > 0

Body:
Hei,

I need a function in php that checks if a value entered by form is already in database (sql - server -- PDO), and return TRUE or FALSE.

I tried to do this, but I got stuck and didn't found a solution on internet.
could you give me a hint on how to threat the above condition ?

function check_code($code) {
GLOBAL $handler;
$code = check_input($code);
        try{
      $query2 = $handler -> prepare("SELECT code from stock where code = :code");
      $query2 -> execute(array(
                    ':code' => $code
                    ));
return  >???<
        }
        catch(PDOException $e){
            echo $e -> getMessage();
      }  }


问:
how to import Bootstrap

I saw some examples,bu it don't solve my problem!

Any help will be Appreciated....

答:
I have solved this problem ,the version of the Django is 1.11. I check the Django website,it told me I must build files like this and set setting.py like this.But thanks for all of you!
enter image description here</p>

Title: how to import Bootstrap


问:
CoordinatorLayout and AppBarLayout elevation
I've created an AppBar layout like this

```<code><android.support.design.widget.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/appbar_layout"
    android:layout_height="@dimen/app_bar_height"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:elevation="20dp">

    <android.support.design.widget.CollapsingToolbarLayout...>
</android.support.design.widget.AppBarLayout>
</code>```

it works and casts a shadow in the LinearLayout:

```<code><LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/app_bar_large" />
</LinearLayout>
</code>```

However when I put it into the CoordinatorLayout shadow is gone:

```<code><android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/app_bar_large" />
</android.support.design.widget.CoordinatorLayout>
</code>```

How can I make appbar to show its shadow again?

答:
the reason is above,try this to solve:</p>

```<code>appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            //some other code here
            ViewCompat.setElevation(appBarLayout, The Elevation In Px);
        }
    });
</code>```

Body:
I've created an AppBar layout like this

<android.support.design.widget.AppBarLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/appbar_layout"
    android:layout_height="@dimen/app_bar_height"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:elevation="20dp">

    <android.support.design.widget.CollapsingToolbarLayout...>
</android.support.design.widget.AppBarLayout>

it works and casts a shadow in the LinearLayout:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/app_bar_large" />
</LinearLayout>

However when I put it into the CoordinatorLayout shadow is gone:

<android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/app_bar_large" />
</android.support.design.widget.CoordinatorLayout>

How can I make appbar to show its shadow again?

Body:
the reason is above,try this to solve:

appBarLayout.addOnOffsetChangedListener(new AppBarLayout.OnOffsetChangedListener() {
        @Override
        public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
            //some other code here
            ViewCompat.setElevation(appBarLayout, The Elevation In Px);
        }
    });


问:
Can any one give me some advice to make my for loop more efficient?
So I have this for loop with 36 if-queries inside. Any advice on making it more efficient?
You can view the complete code  here

Here's a sample of what it looks like:

```<code>$numbers = range(1, 36);
shuffle($numbers);
for ($m =0; $m<37; $m++){
    if ($numbers[$m] == "1"){
        $mirza[$m] = "RUTHIE";
        $mage[$m] = "3";
        $mquote[$m] = "I get to learn a lot of new things here, like sign language!";
        $link[$m] = "http://www.google.com";
    }

    if ($numbers[$m] == "2"){
        $mirza[$m] = "AIDA";
        $mage[$m] = "82";
        $mquote[$m] = "This is like a club and I know and like all the members. It's good therapy.";
        $link[$m] = "/about/";
    }

    if ($numbers[$m] == "3"){
        $mirza[$m] = "AMIRE";
        $mage[$m] = "4";
        $mquote[$m] = "I am learning how to share and make friends.";
        $link[$m] = "/about/";
    }
}
</code>```

答:
Is your problem that you feel you simply have too many "if" statements? Try a switch statement. Technically speaking, your loop is about as efficient as possible (using big-O method of evaluating efficiency).</p>

```<code>for ($m =0; $m<37; $m++){
    switch($numbers[$m])
    {
        case 1:
            $mirza[$m] = "RUTHIE";
            $mage[$m] = "3";
            $mquote[$m] = "I get to learn a lot of new things here, like sign language!";
            $link[$m] = "http://www.google.com";
        break;
        case 2:
            $mirza[$m] = "AIDA";
            $mage[$m] = "82";
            $mquote[$m] = "This is like a club and I know and like all the members. It's good therapy.";
            $link[$m] = "/about/";
        break;
        case 3:
            $mirza[$m] = "AMIRE";
            $mage[$m] = "4";
            $mquote[$m] = "I am learning how to share and make friends.";
            $link[$m] = "/about/";
        break;
    }
}
</code>```

Body:
So I have this for loop with 36 if-queries inside. Any advice on making it more efficient?
You can view the complete code  here

Here's a sample of what it looks like:

$numbers = range(1, 36);
shuffle($numbers);
for ($m =0; $m<37; $m++){
    if ($numbers[$m] == "1"){
        $mirza[$m] = "RUTHIE";
        $mage[$m] = "3";
        $mquote[$m] = "I get to learn a lot of new things here, like sign language!";
        $link[$m] = "http://www.google.com";
    }

    if ($numbers[$m] == "2"){
        $mirza[$m] = "AIDA";
        $mage[$m] = "82";
        $mquote[$m] = "This is like a club and I know and like all the members. It's good therapy.";
        $link[$m] = "/about/";
    }

    if ($numbers[$m] == "3"){
        $mirza[$m] = "AMIRE";
        $mage[$m] = "4";
        $mquote[$m] = "I am learning how to share and make friends.";
        $link[$m] = "/about/";
    }
}

Body:
Is your problem that you feel you simply have too many "if" statements? Try a switch statement. Technically speaking, your loop is about as efficient as possible (using big-O method of evaluating efficiency).

for ($m =0; $m<37; $m++){
    switch($numbers[$m])
    {
        case 1:
            $mirza[$m] = "RUTHIE";
            $mage[$m] = "3";
            $mquote[$m] = "I get to learn a lot of new things here, like sign language!";
            $link[$m] = "http://www.google.com";
        break;
        case 2:
            $mirza[$m] = "AIDA";
            $mage[$m] = "82";
            $mquote[$m] = "This is like a club and I know and like all the members. It's good therapy.";
            $link[$m] = "/about/";
        break;
        case 3:
            $mirza[$m] = "AMIRE";
            $mage[$m] = "4";
            $mquote[$m] = "I am learning how to share and make friends.";
            $link[$m] = "/about/";
        break;
    }
}


问:
The controller with the name x is not registered
I can't figure out why i've this "controller is not registered" error in angular 1.6.4.

Controller:

```<code>var app = angular.module('app', ['ngRoute']);
app.controller("formCtrl", function($scope, $rootScope, $stateParams) {
  $scope.id = $stateParams.id;
});
</code>```

Index:

```<code><html>
  <head>
    <script src="js/angular.js"></script>
    <script src="js/angular-route.js"></script>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script src="js/formCtrl.js" type="text/javascript"></script>
    <script src="js/app.js" type="text/javascript"></script>
  </head>
  <body ng-app="app">
    <div ng-view>
    </div>
  </body>
</html>
</code>```

App:

```<code>app = angular.module('app', ['ngRoute']);

app.config(function($routeProvider) {
  $routeProvider
  .when("/:id", {
    templateUrl: './partials/main.html',
    controller: 'formCtrl'
  });
})
</code>```

答:
This is because you're actually creating a new module for the controller, instead of reusing the existing app module.

To fix this you simply change your controller code to this:

```<code>angular.module('app').controller("formCtrl", function($scope, $rootScope, $stateParams) {
  $scope.id = $stateParams.id;
});
</code>```

You only need to specify the second argument of angular.module() when you intent to create a new module. If you want to register controllers, components, services, etc. for your application, you only apply the first argument: angular.module('app').

Note, make sure your controller js file is loaded after the app js file.

Body:
I can't figure out why i've this "controller is not registered" error in angular 1.6.4.

Controller:

var app = angular.module('app', ['ngRoute']);
app.controller("formCtrl", function($scope, $rootScope, $stateParams) {
  $scope.id = $stateParams.id;
});

Index:

    <meta http-equiv="content-type" content="text/html; charset=utf-8" />

App:

app = angular.module('app', ['ngRoute']);

app.config(function($routeProvider) {
  $routeProvider
  .when("/:id", {
    templateUrl: './partials/main.html',
    controller: 'formCtrl'
  });
})

Body:
This is because you're actually creating a new module for the controller, instead of reusing the existing app module.

To fix this you simply change your controller code to this:

angular.module('app').controller("formCtrl", function($scope, $rootScope, $stateParams) {
  $scope.id = $stateParams.id;
});

You only need to specify the second argument of angular.module() when you intent to create a new module. If you want to register controllers, components, services, etc. for your application, you only apply the first argument: angular.module('app').

Note, make sure your controller js file is loaded after the app js file.


问:
NotFound route always showing with static routes - [React Router 4]
How can I define a notFound component with React Router 4 and static routes?

I use the nextversion of react-router-redux. So, in my client:

```<code>export default function appRoutes(history) {
  return (
    <ConnectedRouter history={history}>
      <div>
        {routes.map((route, key) => (
          <Route key={key} {...route} />
        ))}
      </div>
    </ConnectedRouter>
  );
}
</code>```

And routes is:

```<code>export const routes = [
  {
    path: '/',
    component: App
  },
  {
    path: '/:lang/chat',
    component: Chat
  },
  {
    path: '/:lang',
    component: Listing
  },
  ...
  {
    path: '*',
    component: NotFound,
    status: 404
  },
];
</code>```

With this approach, the component not found is always showing along with the matched route.

I have read that instead of wrapping the appRoutes method described above, with a div, I have to use Switch. But with this approach, the routes never match.

EDIT

I want to display, for example, App component and Listing component at the same time but the NotFound is also displaying.

So, what I'm doing wrong?

答:
I found a solution that works for me. I have removed from static routes the App component and placed before and then I used Switch to render only one route.

```<code>export default function appRoutes(history) {
  return (
    <ConnectedRouter history={history}>
      <div>
        <Route path='/' component={App} />
        <Switch>
          {routes.map((route, key) => (
            <Route key={key} {...route} />
          ))}
        </Switch>
      </div>
    </ConnectedRouter>
  );
}
</code>```

Body:
How can I define a notFound component with React Router 4 and static routes?

I use the nextversion of react-router-redux. So, in my client:

export default function appRoutes(history) {
  return (
    <ConnectedRouter history={history}>

        {routes.map((route, key) => (
          <Route key={key} {...route} />
        ))}

    </ConnectedRouter>
  );
}

And routes is:

export const routes = [
  {
    path: '/',
    component: App
  },
  {
    path: '/:lang/chat',
    component: Chat
  },
  {
    path: '/:lang',
    component: Listing
  },
  ...
  {
    path: '*',
    component: NotFound,
    status: 404
  },
];

With this approach, the component not found is always showing along with the matched route.

I have read that instead of wrapping the appRoutes method described above, with a div, I have to use Switch. But with this approach, the routes never match.

EDIT

I want to display, for example, App component and Listing component at the same time but the NotFound is also displaying.

So, what I'm doing wrong?

Body:
I found a solution that works for me. I have removed from static routes the App component and placed before and then I used Switch to render only one route.

export default function appRoutes(history) {
  return (
    <ConnectedRouter history={history}>
      <div>
        <Route path='/' component={App} />
        <Switch>
          {routes.map((route, key) => (
            <Route key={key} {...route} />
          ))}
        </Switch>
      </div>
    </ConnectedRouter>
  );
}


问:
Get plugin version number octoberCMS
I was wondering if it is possible to get the plugin version number in an octoberCMS plugin, and how this is done. i've been looking for this on google but can't seem to find anything on the subject.

I'm trying to get the number in a controller, but if it is possible in any other way it would be great to hear.

Thanks in advance.

答:
@Jasper de Vries
you can check the version of plugin inside the version.yaml file under updates directory of the plugin.

Title: Get plugin version number octoberCMS


问:
How to create Gradient overlay above ActionBar
I want to create a customised action bar. Which will be combining the app theme colour with the gradient overlay to get a new gradient. I have pasted my gradient file and the background colour codes. Can anyone tell me how to do this?

```<code><?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:useLevel="false" >

    <gradient
        android:angle="0"
        android:startColor="@color/gradient_start_colour"
        android:endColor="@color/gradient_end_colour"
        android:type="linear" />

</shape>
</code>```

And theme colour for app is #0097a7 . Can anyone tell me if this is possible and if yes, how to do it?

答:
You can create drawable like this,

drawable/toolbar_bg.xml

```<code><?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
               android:shape="rectangle">
            <solid android:color="#0097a7"/>

            <gradient
                android:angle="9"
                android:endColor="#FFF"
                android:startColor="#55FFFFFF"
                android:type="linear"/>
        </shape>
    </item>

</layer-list>
</code>```

and in toolbar you can give background like this,

```<code><android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@drawable/toolbar_bg"
                app:popupTheme="@style/AppTheme.PopupOverlay">

            </android.support.v7.widget.Toolbar>
</code>```

Body:
I want to create a customised action bar. Which will be combining the app theme colour with the gradient overlay to get a new gradient. I have pasted my gradient file and the background colour codes. Can anyone tell me how to do this?

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:useLevel="false" >

    <gradient
        android:angle="0"
        android:startColor="@color/gradient_start_colour"
        android:endColor="@color/gradient_end_colour"
        android:type="linear" />

</shape>

And theme colour for app is #0097a7 . Can anyone tell me if this is possible and if yes, how to do it?

Body:
You can create drawable like this,

drawable/toolbar_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape xmlns:android="http://schemas.android.com/apk/res/android"
               android:shape="rectangle">
            <solid android:color="#0097a7"/>

            <gradient
                android:angle="9"
                android:endColor="#FFF"
                android:startColor="#55FFFFFF"
                android:type="linear"/>
        </shape>
    </item>

</layer-list>

and in toolbar you can give background like this,

<android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="@drawable/toolbar_bg"
                app:popupTheme="@style/AppTheme.PopupOverlay">

            </android.support.v7.widget.Toolbar>


问:
How do I load a xib file from my cocoapod?
My xib files are in the Assets folder of my Pod like this.

```<code>s.resources = 'Pod/Assets'
</code>```

The xib files show up in my workspace in the Development Pods group of the cocoa pod.  I'm trying to access the xib like this.

```<code>[[NSBundle mainBundle] loadNibNamed:@"LabeledTextFieldView" owner:self options:nil];
</code>```

But I get the following crash

```<code>*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jeff.wolski/Library/Application Support/iPhone Simulator/7.1/Applications/775EB653-519B-4FCF-8CD9-92311E205598/LT-Components-iOS.app> (loaded)' with name 'LabeledTextFieldView''
</code>```

Why is the xib file not found in the bundle?

答:
In here you need to add this into your pod spec.

```<code> s.resources = "YourProjectName/*.xib"
 s.resource_bundles = {
   'YourProjectName' => [
       'Pod/**/*.xib'
   ]
 }
</code>```

Then retrieve the xib file from the bundle like this:-

```<code> let podBundle = Bundle(for:YourClassName.self)
    if let bundleURL = podBundle.url(forResource: "YourProjectName", withExtension: "bundle") {
        if let bundle = Bundle(url: bundleURL) {
            let cellNib = UINib(nibName: "nibFileName", bundle: bundle)
            navigationTableView.register(cellNib, forCellReuseIdentifier: "nibFileReuseIdentifierName")
        } else {
            assertionFailure("Could not load the bundle")
        }
    } else {
        assertionFailure("Could not create a path to the bundle")
    }
</code>```

Body:
My xib files are in the Assets folder of my Pod like this.

s.resources = 'Pod/Assets'

The xib files show up in my workspace in the Development Pods group of the cocoa pod.  I'm trying to access the xib like this.

[[NSBundle mainBundle] loadNibNamed:@"LabeledTextFieldView" owner:self options:nil];

But I get the following crash

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jeff.wolski/Library/Application Support/iPhone Simulator/7.1/Applications/775EB653-519B-4FCF-8CD9-92311E205598/LT-Components-iOS.app> (loaded)' with name 'LabeledTextFieldView''

Why is the xib file not found in the bundle?

Body:
In here you need to add this into your pod spec.

 s.resources = "YourProjectName/*.xib"
 s.resource_bundles = {
   'YourProjectName' => [
       'Pod/**/*.xib'
   ]
 }

Then retrieve the xib file from the bundle like this:-

 let podBundle = Bundle(for:YourClassName.self)
    if let bundleURL = podBundle.url(forResource: "YourProjectName", withExtension: "bundle") {
        if let bundle = Bundle(url: bundleURL) {
            let cellNib = UINib(nibName: "nibFileName", bundle: bundle)
            navigationTableView.register(cellNib, forCellReuseIdentifier: "nibFileReuseIdentifierName")
        } else {
            assertionFailure("Could not load the bundle")
        }
    } else {
        assertionFailure("Could not create a path to the bundle")
    }


问:
Javascript and website loading time optimization
I know that best practice for including javascript is having all code in a separate .js file and allowing browsers to cache that file.

But when we begin to use many jquery plugins which have their own .js, and our functions depend on them, wouldn't it be better to load dynamically only the js function and the required .js for the current page?

Wouldn't that be faster, in a page, if I only need one function to load dynamically embedding it in html with the script tag instead of loading the whole js with the js plugins?

In other words, aren't there any cases in which there are better practices than keeping our whole javascript code in a separate .js?

答:
I keep separate files for each plug-in and page during development, but during production I merge-and-minify all my JavaScript files into a single JS file loaded uniformly throughout the site. My main layout file in my web framework (Sinatra) uses the deployment mode to automatically either generate script tags for all JS files (in order, based on a manifest file) or perform the minification and include a single querystring-timestamped script inclusion.

Every page is given a body tag with a unique id, e.g. .

For those scripts that need to be specific to a particular page, I either modify the selectors to be prefixed by the body:

```<code>$('body#contact form#contact').submit(...);
</code>```

or (more typically) I have the onload handlers for that page bail early:

```<code>jQuery(function($){
  if (!$('body#contact').length) return;
  // Do things specific to the contact page here.
});
</code>```

Yes, including code (or even a plug-in) that may only be needed by one page of the site is inefficient if the user never visits that page. On the other hand, after the initial load the entire site's JS is ready to roll from the cache.

Body:
I keep separate files for each plug-in and page during development, but during production I merge-and-minify all my JavaScript files into a single JS file loaded uniformly throughout the site. My main layout file in my web framework (Sinatra) uses the deployment mode to automatically either generate script tags for all JS files (in order, based on a manifest file) or perform the minification and include a single querystring-timestamped script inclusion.

Every page is given a body tag with a unique id, e.g. <body id="contact">.

For those scripts that need to be specific to a particular page, I either modify the selectors to be prefixed by the body:

$('body#contact form#contact').submit(...);

or (more typically) I have the onload handlers for that page bail early:

jQuery(function($){
  if (!$('body#contact').length) return;
  // Do things specific to the contact page here.
});

Yes, including code (or even a plug-in) that may only be needed by one page of the site is inefficient if the user never visits that page. On the other hand, after the initial load the entire site's JS is ready to roll from the cache.


问:
Is it possible to create some IGrouping object
I have List<IGrouping<string,string>>.

Is is somehow possible to add new item to this list? Or actually, is it possible to create some IGrouping object?

答:
```<code>IGrouping<TKey, TElement> CreateGroup<TKey, TElement>(IEnumerable<TElement> theSeqenceToGroup, TKey valueForKey)
{
    return theSeqenceToGroup.GroupBy(stg => valueForKey).FirstOrDefault();
}
</code>```


问:
Error in ng serve after installing npm angular/cli
I am a beginner in learning nodejs and angular. I have installed node and created a node project which was working fine. Then I did "npm install -g angular-cli" and after that i did ng new client and inside client when i do "ng serve" i am getting the following error:</p>

```<code>The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\node_modules\@ngtools\webpack\src\index.js:14:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\typescript.js:3:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\index.js:9:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-config.js:4:25)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\tasks\serve.js:11:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.run.js:6:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Class.run (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.js:67:16)
    at Class.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\ember-cli\lib\models\command.js:134:17)
    at process._tickCallback (internal/process/next_tick.js:109:7)
</code>```

答:
You may have older versions.

See the instructions here and see if that helps: https://github.com/angular/angular-cli/wiki/stories-1.0-update

The steps are basically:

Uninstall old version

Update node/npm if necessary

Install new version

The link provides specifics for each of these steps along with appropriate commands.

Body:
I am a beginner in learning nodejs and angular. I have installed node and created a node project which was working fine. Then I did "npm install -g angular-cli" and after that i did ng new client and inside client when i do "ng serve" i am getting the following error:

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\node_modules\@ngtools\webpack\src\index.js:14:11)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\typescript.js:3:17)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-configs\index.js:9:10)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\models\webpack-config.js:4:25)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\tasks\serve.js:11:24)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.run.js:6:15)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Class.run (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\commands\serve.js:67:16)
    at Class.<anonymous> (C:\Users\Subhasree\AppData\Roaming\npm\node_modules\angular-cli\ember-cli\lib\models\command.js:134:17)
    at process._tickCallback (internal/process/next_tick.js:109:7)


问:
connection to postgres database
I'm trying to connect to a PostgreSQL database but it's showing file not found.

I'm taking input from a form and trying to add these inputs in DB.
Is my code correct? The database is connecting in Netbeans but not taking values online.

```<code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Admin
 */
public class login extends HttpServlet {

    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, ClassNotFoundException {
        response.setContentType("text/html;charset=UTF-8");
         String name= request.getParameter("name");
          String lname= request.getParameter("lname");
          String dob= request.getParameter("dob");
          String email=request.getParameter("email");
          String password = request.getParameter("password");
          String mobilenumber= request.getParameter("mobilenumber");
          String epertiselevel=request.getParameter("epertiselevel");

        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
             Class.forName("org.postgresql.Driver");
           Connection con =DriverManager.getConnection
                     ("jdbc:postgresql://localhost:5434/mydb","postgres","admin");
              PreparedStatement ps=con.prepareStatement("insert into \"public\".\"user\"  values('"+name+"','"+dob+"','"+email+"','"+password+"','"+mobilenumber+"','"+epertiselevel+"')");
               ps.setString(1, name);
        ps.setString(2, lname);
        ps.setString(3, dob);
        ps.setString(4, email);
        ps.setString(5, password);
        ps.setString(6, mobilenumber);
        ps.setString(7, epertiselevel);
          Statement stmt=con.createStatement();
            int i = 0;
           if(i>0)
          {
            out.println("You are sucessfully registered");
          }else{
      out.println("Failed in  registration");
      }
        } catch (SQLException se) {
           se.printStackTrace();
        }

    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}
</code>```

<!DOCTYPE html>

SIGNUP

<form name="myForm" action="login" method="post">
Name: <input type="text" name="name">

Last Name:<input type="text" name="lname">

DOB:<input type="date" name="dob">

EMAIL:<input type="text" name="email">

Password<input type="password" value="password" name="password">

    Mobile No:<input type="text" name="mobilenumber">

Expertise Level in Biodiversity:
<input type="radio" name="epertiselevel" value="begginer">Begginer

<input type="radio" name="epertiselevel" value="intermediate">Intermediate

<input type="radio" name="epertiselevel" value="advanced">Advanced

<input type="radio" name="epertiselevel" value="nothing">Nothing

<input type="submit" value="SIGNUP">
<input type="reset" value="Reset">
</form>

```

答:
initially i was trying to connect t postgres via servlet
but now whrn i write this code in jsp its working correctly
Im showing a demo of connection to postgres.
try connect to postgres via jsp its working

jsp code

SIGNUP

<%
    String user_name = request.getParameter("u_name");
        String user_email = request.getParameter("u_email");
        String user_pass = request.getParameter("u_pass");
    Class.forName("org.postgresql.Driver");
try{
Connection conn=DriverManager.getConnection("jdbc:postgresql://localhost:5434/mydb","postgres","admin");

PreparedStatement ps;
  ps=conn.prepareStatement("insert into public.registration values(?,?,?)");

        ps.setString(1, user_name);
        ps.setString(2, user_email);
        ps.setString(3, user_pass);
        int i=ps.executeUpdate();

          if(i>0)
          {
            out.println("You are sucessfully registered");
          }else{
   out.println("Failed in  registration");
   }

        }
        catch(Exception se)
        {
            se.printStackTrace();
        }

%>

```
<pre class="snippet-code-html lang-html prettyprint-override"><code>!DOCTYPE HTML>
<html>
    <head>
        <title>Registration </title>
    </head>
    <body>
        <h1>hjhjj</h1>
        <form method="post" action="first.jsp">
        User Name:<input type="text" name="u_name" /><br/>
        User Email ID:<input type="text" name="u_email" /><br/>
        User Password:<input type="text" name="u_pass" /><br/>
        <input type="submit" value="register" />
        </form>
    </body>
</html></code>```

Title: connection to postgres database

Body:
I'm trying to connect to a PostgreSQL database but it's showing file not found.

I'm taking input from a form and trying to add these inputs in DB.
Is my code correct? The database is connecting in Netbeans but not taking values online.

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Admin
 */
public class login extends HttpServlet {

    /**
     * Processes requests for both HTTP GET and POST
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException, ClassNotFoundException {
        response.setContentType("text/html;charset=UTF-8");
         String name= request.getParameter("name");
          String lname= request.getParameter("lname");
          String dob= request.getParameter("dob");
          String email=request.getParameter("email");
          String password = request.getParameter("password");
          String mobilenumber= request.getParameter("mobilenumber");
          String epertiselevel=request.getParameter("epertiselevel");

        try (PrintWriter out = response.getWriter()) {
            /* TODO output your page here. You may use following sample code. */
             Class.forName("org.postgresql.Driver");
           Connection con =DriverManager.getConnection
                     ("jdbc:postgresql://localhost:5434/mydb","postgres","admin");
              PreparedStatement ps=con.prepareStatement("insert into \"public\".\"user\"  values('"+name+"','"+dob+"','"+email+"','"+password+"','"+mobilenumber+"','"+epertiselevel+"')");
               ps.setString(1, name);
        ps.setString(2, lname);
        ps.setString(3, dob);
        ps.setString(4, email);
        ps.setString(5, password);
        ps.setString(6, mobilenumber);
        ps.setString(7, epertiselevel);
          Statement stmt=con.createStatement();
            int i = 0;
           if(i>0)
          {
            out.println("You are sucessfully registered");
          }else{
      out.println("Failed in  registration");
      }
        } catch (SQLException se) {
           se.printStackTrace();
        }

    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP GET method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Handles the HTTP POST method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(login.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>

}

<!DOCTYPE html>

SIGNUP

<form name="myForm" action="login" method="post">
Name: <input type="text" name="name">

Last Name:<input type="text" name="lname">

DOB:<input type="date" name="dob">

EMAIL:<input type="text" name="email">

Password<input type="password" value="password" name="password">

    Mobile No:<input type="text" name="mobilenumber">

Expertise Level in Biodiversity:
<input type="radio" name="epertiselevel" value="begginer">Begginer

<input type="radio" name="epertiselevel" value="intermediate">Intermediate

<input type="radio" name="epertiselevel" value="advanced">Advanced

<input type="radio" name="epertiselevel" value="nothing">Nothing

<input type="submit" value="SIGNUP">
<input type="reset" value="Reset">
</form>

Body:
initially i was trying to connect t postgres via servlet
but now whrn i write this code in jsp its working correctly
Im showing a demo of connection to postgres.
try connect to postgres via jsp its working

jsp code

<style>
    h1{background-color:orange;color:white;}
    body{background-color:lightblue}
</style>
    </head>
<body>
<h1>SIGNUP</h1>
<%
    String user_name = request.getParameter("u_name");
        String user_email = request.getParameter("u_email");
        String user_pass = request.getParameter("u_pass");
    Class.forName("org.postgresql.Driver");
try{
Connection conn=DriverManager.getConnection("jdbc:postgresql://localhost:5434/mydb","postgres","admin");

PreparedStatement ps;
  ps=conn.prepareStatement("insert into public.registration values(?,?,?)");

        ps.setString(1, user_name);
        ps.setString(2, user_email);
        ps.setString(3, user_pass);
        int i=ps.executeUpdate();

          if(i>0)
          {
            out.println("You are sucessfully registered");
          }else{
   out.println("Failed in  registration");
   }

        }
        catch(Exception se)
        {
            se.printStackTrace();
        }

%>
</body>
</html>

!DOCTYPE HTML>
<html>
    <head>
        <title>Registration </title>
    </head>
    <body>
        <h1>hjhjj</h1>
        <form method="post" action="first.jsp">
        User Name:<input type="text" name="u_name" /><br/>
        User Email ID:<input type="text" name="u_email" /><br/>
        User Password:<input type="text" name="u_pass" /><br/>
        <input type="submit" value="register" />
        </form>
    </body>
</html>