javascript - Unterminated String Literal from getServletContext().getRealPath("/") in JSP -


This is an error that came after the last question in my reply. Basically I'm trying to bring the abs path to the folder with me, so I can file something on the runtime, even if my code is located. I was recommended to use

  getServletContext (). GetRealPath ("/");  

Here is the script that I try to run.

  & lt; Script type = "text / javascript" & gt; Var RemoteUserId = "& lt;% = (request.getRemoteUser () == faucet)?" Blah ": request.getRemoteUser ()%>"; Var reference path = "& lt;% = request.getContextPath ()%>"; Var extapath = "& lt;% = extapath%>"; Var absPath = "& lt;% = getServletContext (). GetRealPath (" / ")%>"; Var env = '& lt;% = string1% & gt;'; & Lt; / Script & gt;   

What am I missing? Did I return the path that was returned to me, or when I used to use it, I misread it.

Edit ** The source is that when it reaches the page it shows '
' is not showing me full path: path)

   absPath  variable should end  
  var absPath = "C: \\ documents and settings ... \ \ TRACK \\";   

You can do this

  var abspath = "& lt;% = getServletContext (). GetRealPath (" / ").", "\ \\ "")%> ";   

But still, I have no point in returning Java version to Java via JavaScript. When the code is about processing the request, just log in it to Java. Imagine that you are using the servlet to process the request, just do it

  string absPath = getServletContext (). GetRealPath ("/");   

instead of

  string abspath = request.getParameter ("absPath");   

(or whatever you are doing to get abspath back in your code)

Also keep in mind that all javascript Code Client is fully controllable / fraud / hackable client running, while javascript is capable of editing variables. For example, the customer can change the path before using it. Keep this in mind!

Comments