I am passing a variable value which is gained with in JSP page to a servlet page. I used sessions. But it gives the following NullPointerException.  java.lang.NullPointerException     com.google.api.client.http.GenericUrl.appendParam(GenericUrl.java:599)     com.google.api.client.http.GenericUrl.addQueryParams(GenericUrl.java:582)     com.google.api.client.http.UriTemplate.expand(UriTemplate.java:346)     com.google.api.client.http.UriTemplate.expand(UriTemplate.java:259)     com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequestUrl(AbstractGoogleClientRequest.java:266)     com.google.api.client.googleapis.services.AbstractGoogleClientRequest.buildHttpRequest(AbstractGoogleClientRequest.java:301)     com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419)     com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352)     com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469)     com.translator.api.TranslatorApi.getTranslate(TranslatorApi.java:66)     control.TextTranslation.doPost(TextTranslation.java:47)     javax.servlet.http.HttpServlet.service(HttpServlet.java:650)     javax.servlet.http.HttpServlet.service(HttpServlet.java:731)     org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)   imageExtract.jsp  &lt;/div&gt;         &lt;div class="row"&gt;             &lt;div  id = "display" class="col-lg-8 center-block "&gt;             &lt;%             String extracted = (String) request.getAttribute("extractedText");             session.setAttribute("text", extracted);              %&gt;                 &lt;textarea maxlength="200" class=" form-control " name="msg" rows="20" id="Extract-textarea" &gt;&lt;%=extracted %&gt; &lt;/textarea&gt;              &lt;/div&gt;     &lt;/div&gt;   TextTranslate.java  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {      PrintWriter out = response.getWriter();     String language = "ES";     HttpSession extractedText = request.getSession();     String imageName = (String) extractedText.getAttribute("extractedText");     System.out.println("this is so stupid");     System.out.println("This is "+imageName);     TranslatorApi translation = new TranslatorApi();      String outputText =   translation.getTranslate(imageName, language);     System.out.println("Second"+outputText);     request.setAttribute("outputText", outputText);     RequestDispatcher sndValue = request.getRequestDispatcher("/translation.jsp");     sndValue.forward(request, response);  }   The problem is that the session value is not passed to the servlet, which gives a NullpointerException. Why might this be happening?
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
Which is correct: "drive safe" or "drive safely"? When someone is going to drive their car somewhere, I always used to say "drive safely" to them. Recently I was told I should say "drive safe."    (From: )   Which one is correct?  Similarly, is "do good" correct? Can I gift a game via the PlayStation Network? Is it possible to "gift" a game (e.g., Castle Crashers) to someone through the PlayStation Network?  I don't have a PS3 but was considering buying Castle Crashers as a gift for a friend so that we could play co-op.  Is this possible? Does a Grapple or Shove count as an attack for the Mobile feat? The  feat enables you to not get opportunity attacks from creatures you try to attack.  Does it still apply if the attack you made was a Grapple or Shove ? What does ;; do in sh? Proving that ${x +y+n- 1 \choose n}= \sum_{k=0}^n{x+n-k-1 \choose n-k}{y+k-1 \choose k} $ How can I prove that $${x +y+n- 1 \choose n}= \sum_{k=0}^n{x+n-k-1 \choose n-k}{y+k-1 \choose k} $$  I tried the following:  We use the :  $$y^{\underline k}=\underbrace{y(y-1)(y-2)\ldots(y-k+1)}_{k\text{ factors}},$$ so that $\binom{y}k=\frac{y^{\underline k}}{k!} .$   Then  $${x +y+n- 1 \choose n} = \frac{(x +y+n- 1)!}{n! ((x +y+n- 1) - n)!} =  \frac{1}{n!}. (x +y+n \color{#f00}{-1})^{\underline n} $$  And  $$ {x+n-k-1 \choose n-k}{y+k-1 \choose k}$$ $$\frac{1}{(n-k)!}.(x+n-k-1)^{\underline{n-k}}.\frac{1}{k!}.(y+k-1)^{\underline{k}}$$ $$\frac{1}{k!.(n-k)!}.(x+n-k-1)^{\underline{n-k}}.(y+k-1)^{\underline{k}}$$ $$\sum_{k=0}^n{n \choose k}(x+n-k-1)^{\underline{n-k}}.(y+k-1)^{\underline{k}}$$  According to the Binomial-coefficients:  $$ ((x+n-k-1) + (y+k-1))^{\underline{n}}$$ $$ (x+y+n\color{#f00}{- 2})^{\underline{n}}$$  What is wrong ? und How can I continue?  :/ Turn a string into a valid filename? I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python.  I'd rather be strict than otherwise, so let's say I want to retain only letters, digits, and a small set of other characters like "_-.() ". What's the most elegant solution?  The filename needs to be valid on multiple operating systems (Windows, Linux and Mac OS) - it's an MP3 file in my library with the song title as the filename, and is shared and backed up between 3 machines. Fontspec causes long underscores My collaborator added \usepackage[no-math]{fontspec} to a document we're working on. The result is that \_ underscores become v. long: cf. pictures below.   \documentclass{article} \usepackage[no-math]{fontspec} \pagestyle{empty}  \begin{document} \textrm{metric\_space} \end{document}   With fontspec:    Without fontspec:   The underscores are about twice as long with fontspec, and also much thinner. My question is, how do I get back to the original width? (Ideally I would like to preserve the thinness -- it looks much nicer than the original.)  In case someone asks, "why are you using \_?", the short answer is that I need to typeset identifiers involving an underscore. See  for an example in context. I'd be happy with using something other than \textrm, if it looks decent in the context of that example. Continuity of $L^1$ functions with respect to translation Setting up LVM Snapshot as a backup/restore point in ubuntu How do the Hat Dash points work? How to submit webform programmaticaly? How do I summon the Golem? Why do all SSH-RSA Keys begin with "AAAAB3NzaC1yc"? Gravity in 2d space and inverse linear law In our three-dimensional universe, gravity obeys the inverse square law. In a four-dimensional universe, gravity would be expected to obey the inverse cube law et cetera.  In a two-dimensional universe, one would similarly expect gravity to obey an inverse linear law. I've seen it claimed that this is not actually true, when you work it out according to general relativity there would actually be no gravity at all in such a universe. Is this true? If so, is there a layman's explanation of why? Is it related to the fact that gravitational potential wells would be infinitely deep?  Would electrostatic forces follow the same law as gravity?  If there existed infinitely long strings in our universe, would they have the same gravitational effect as point particles in a 2d universe? How do you iterate over each file in a directory with a .bat or .cmd file?  For simplicity please provide an answer that just echoes the filename or file path. Inequality between $\ell^p$-norms Inspired by , say you have a 4x4 two dimensional array, write a function that rotates it 90 degrees. Raymond links to a solution in pseudo code, but I'd like to see some real world stuff.  [1][2][3][4] [5][6][7][8] [9][0][1][2] [3][4][5][6]   Becomes:  [3][9][5][1] [4][0][6][2] [5][1][7][3] [6][2][8][4]   Update: Nick's answer is the most straightforward, but is there a way to do it better than n^2? What if the matrix was 10000x10000? What is the difference between .profile and .bash_profile and why don't I have a .profile file on my system? So I'm pretty new to Linux and recently installed Fedora 19 on my netbook. I want to have a deeper understanding of Linux and the CLI so I'm now reading .  In exercise 3 the author gives the following commands:   ls -al cat .profile   I try to follow these instructions but to no avail. There is no .profile file in my user name directory as I can see from ls -al. From what I've learned the .bash_profile and .profile file are practically the same. The only difference I concluded from my research is that .bash_profile gets checked first.   What I don't understand is why are there multiple files for the same function in Linux, why is the Author using .profile and not .bash_profile (if I understand correctly .profile won't be read when the system finds .bash_profile first) and how comes that I don't have the .profile file on my system? I'm building a Core  system which supports dual-channel memory (up to 16&nbsp;GB in four DIMMs), my target is 8&nbsp;GB. From the performance perspective, is it better to have two times 4&nbsp;GB or four times 2&nbsp;GB? Let $x_1 = 2$, and define $$x_{n+1} = \frac{1}{2} \left(x_n + \frac{2}{x_n}\right).$$ Show that $x_n^2$ is always greater than or equal to $2$, and then use this to prove that $x_n − x_{n+1} ≥ 0$. Conclude that $\lim x_n = \sqrt2$.   My question:  So I know how to do this problem but I don't know how to prove that $x_n &gt;0$ for all $n\in \mathbb{N}$.