• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to achieve this?

 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a code of JSP file stored in database. The code of JSP does all the typical JSP file does.I am getting that code into a String variable.Now I want to execute that code and need generated output in a String variable.
 
karthikeyan Chockalingam
Ranch Hand
Posts: 259
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may obtain the code as a String and save it as a JSP file on the server (web container). Then you may forward the request referring to the relative path of the saved JSP. Example if you have saved the file as ABC.jsp inside jsp/dynamic folder relative to the application under consideration, forward as

getServletContext().getRequestDispatcher("/jsp/dynamic/ABC.jsp").forward(request,response);
[ February 01, 2006: Message edited by: karthi keyan ]
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks karthi keyan !

But I am looking for a solution where I don't have create physical JSP file.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSP files have only meaning as part of a web application. How are you going to execute one without a web app around it? What values would the implicit objects have?
 
Gerardo Tasistro
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He's looking for an equivalent of the php or PERL command "eval". With which you can execute a string as if it were code. I don't know if it can be done given Java's compiled nature.

I've resorted to tagging the JSP and replacing values with my know, but I can't make it notice JSF tags or that soft of things.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gerardo Tasistro:
I don't know if it can be done given Java's compiled nature.


Agreed.
 
Chetan Parekh
Ranch Hand
Posts: 3640
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks all for reply.

We have change the plan and it does not involve the process I mentioned.
[ February 03, 2006: Message edited by: Chetan Parekh ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!