简体   繁体   English

如何在Java版本的Google App Engine中动态更新JSP文件的内容?

[英]How can I dynamically update the contents of a JSP file in the Java version of Google App Engine?

I am currently teaching a software engineering class where approximately 275 students are learning JSP. 我目前正在教授软件工程课程,大约275名学生正在学习JSP。 I would like to be able to provide the students with an online service that enables them to practice their basic JSP skills. 我希望能够为学生提供在线服务,使他们能够练习基本的JSP技能。 The idea is that students will provide some JSP code to pass some pre-determined tests. 想法是,学生将提供一些JSP代码以通过一些预定的测试。

For example: The students will be asked to provide the code for a JSP page that would return "Hello NAME" where NAME is a GET parameter that has been passed in to the page. 例如:将要求学生提供JSP页面的代码,该代码将返回“ Hello NAME”,其中NAME是已传递到页面的GET参数。

A correct response to this question would be. 对这个问题的正确回答是。

Hello <%= request.getParameter("name") %>

I can currently test student submissions like this using a Linux-based solution where I write the submitted student code out to an existing JSP file, fetch the JSP page while passing in GET parameters, wait for Tomcat to reload and compile the JSP page, parse the HTML result, and return the test results to the students. 目前,我可以使用基于Linux的解决方案来测试学生提交的内容,其中将提交的学生代码写到现有的JSP文件中,在传递GET参数的同时获取JSP页面,等待Tomcat重新加载并编译JSP页面,然后进行解析HTML结果,然后将测试结果返回给学生。 This process is rather slow (overwriting JSP file on disk) and does not scale up well. 该过程相当慢(覆盖磁盘上的JSP文件),并且无法很好地扩展。

I'd like to be able to run this JSP "verifier" on the Java-version of Google App Engine which can be configured to scale up automatically when lots of students are practicing at the same time. 我希望能够在Google App Engine的Java版本上运行此JSP“验证程序”,可以将其配置为在许多学生同时练习时自动按比例放大。

My question is, how can I evaluate submitted JSP code in Google App Engine without being able to overwrite the contents of an existing JSP file? 我的问题是,如何在不覆盖现有JSP文件内容的情况下评估Google App Engine中提交的JSP代码? Can I pass the code that I want to run to a JSP page and have that page return the results? 我可以将要运行的代码传递到JSP页面,并让该页面返回结果吗?

I can not figure out out to have the page use the passed in code to do something with the passed in GET parameters. 我无法弄清楚页面是否使用传入的代码对传入的GET参数进行处理。 In short, I'm missing an eval() method. 简而言之,我缺少eval()方法。

Any ideas? 有任何想法吗?

I've never tried this, but I'd look at the Jasper Compiler (Tomcat's implementation of JSP). 我从来没有尝试过,但是我会看看Jasper编译器 (Tomcat的JSP实现)。 It can generate a class file from a .jsp, which you may be able to load from GAE. 它可以从.jsp生成类文件,您可以从GAE加载该文件。 Though I could also imagine the required effort to get it working might be too much. 尽管我也可以想象到使它正常工作所需的努力可能太多了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM