|
|
| Servlet service method |
Expert:sri harsha
Hi EveryOne , I have a simple problem but i dont know whether the approach me going is correct or not, i will explain u my problem I have two classes one is servlet and the other one is normal java class ,What i want to do is that i want to send path of the servlet from servlet to normal class .And in the second class(i.e normal java class) i want to get this path, i wrote the code for stand alone applications it is working fine but for servlet its not working
here is my servlet code....
import java.io.IOException;
import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
public class TestServlet extends HttpServlet { String path; String path1="adadfafasfdsafasfasfasf"; public void service(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{ path=getServletContext().getRealPath("/"); Two t=new Two(); } public String retPath(){ this.path1=path1; return path1; } }
here is my normal java class
public class Two { public Two(){ System.out.println("Called the Test With Class"); TestServlet one=new TestServlet(); String pathFromServet=one.retPath() System.out.println("From the Test With Class---->"+pathFromServet); } }
is there any way to send the path from servlet to normal java class this is very urgent for me |
| Answers |
Hi friend,
If You want to send the path from servlet to normal java class then
use Setting and getting JavaBean properties in JSP and after it set the path in Java Bean Class and visit to :
http://www.roseindia.net/jsp/java-bean-example-jsp.shtml
Thanks
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|