开发者

I cannot launch java method from jsp page

开发者 https://www.devze.com 2023-04-03 09:49 出处:网络
I upload jsp file (index.jsp) and java file (easyTesting.java) on server and cannot launch themethod fromeasyTesting.java.

I upload jsp file (index.jsp) and java file (easyTesting.java) on server and cannot launch the method from easyTesting.java.

Use :

TomCat 6 on UNIX , server version 5.1.41-3ubuntu12.10

this is my index.jsp

`<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  

"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Layer Easy testing</title>
</head>

<body>
<form action="poi.jsp" method="post">
<INPUT type="button" value="Create script file" onClick = <% link.startCode(); %>  

"window.location.reload()"><br>
<br>
Select POIs type
<div align="left"><br>
<input type="radio" name="poi" value="1"  checked > dynamic<br>
<input type="radio" name="poi" value="2">static<br>
<input type="radio" name="poi" value="3"> both<br>

<INPUT type="submit"  value="save"  ><br>

</div>
</form>
</body>
</html>

`

and java file package layar;

 import java.io.*;

 public class easyTesting 
 {
    public  void startCode() 
 {
   File f = new File("http:79.125.23.143/~lezv/layertestnew.php");
    if(!f.exists())
    {
     f.createNewFile();
    }
    else 
    {
     f.delete();
    }
    }enter code here

   }

And when I open http://79.125.23.143:8080/lezv/index.jsp

I get the next errror

description The server encountered an internal error () that prevented it from  开发者_如何学编程 

fulfilling this request.

exception

 org.apache.jasper.JasperException: An exception occurred processing JSP page   

 /index.jsp at line 12

 9: <jsp:useBean id="link" class = "layar.easyTesting" />
 10: <body>
 11: <form action="poi.jsp" method="post">
 12: <INPUT type="button" value="Create script file" onClick = <% link.startCode(); %>   

 "window.location.reload()"><br>
 13: <br>
 14: Select POIs type
 15: <div align="left"><br>


 Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.ja 
 va:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:407)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
  root cause

  java.io.IOException: Permission denied
java.io.UnixFileSystem.createFileExclusively(Native Method)
java.io.File.createNewFile(File.java:900)
layar.easyTesting.startCode(easyTesting.java:12)
org.apache.jsp.index_jsp._jspService(index_jsp.java:73)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:2

Could you please help me


The method is being called, but encounters an exception:

java.io.IOException: Permission denied
java.io.UnixFileSystem.createFileExclusively(Native Method)
java.io.File.createNewFile(File.java:900)
layar.easyTesting.startCode(easyTesting.java:12)

The exception says that you do not have permissions to create the file.

File f = new File("http:79.125.23.143/~lezv/layertestnew.php");

That is a bit of a weird file name. Could it be that you need to translate the URL you want that PHP to have into a local file path? As it is, those slashes will most likely be interpreted as directory names, so you'd need to at least make sure that any parent directories exist.

0

精彩评论

暂无评论...
验证码 换一张
取 消