简体   繁体   English

使用perl将一个html页面重定向到另一个页面

[英]Redirect one html page to another using perl

I have a html form 我有一个HTML表单

<form id="branch" method="get" action="/x/local/.../perl_code.pl">

Branch Name : <input type="text" name="textBox">

<input type="submit" value="Generate">
</form>

and in perl_code.pl I have this 在perl_code.pl我有这个

use strict;
use warnings;

use CGI qw(:standard);
my $value = uc(param('textBox'));
system "perl /x/local/.../perl_CODE21.pl $value";
#other system commands that work and output the index2.html
print redirect(-url=>'http://server.com:8080/project_name/index2.html');

What I eventually want to do is, get the input from the text box in index1.html retrieve the value in perl_code and do some system commands which print out index2.html and finally redirect it to index2.html . 我最终想要做的是,得到在文本框中输入index1.html检索值perl_code ,做一些system ,其打印出的命令index2.html最后重定向它index2.html I have tried to manually inspect all other system commands and their output, they work. 我试图手动检查所有其他系统命令及其输出,它们工作。 I am not able to retrieve the text value and pass it and also redirecting does not work. 我无法检索文本值并将其传递,并且重定向也不起作用。 The browser redirects to perl_code.pl and gives a 404. I am currently running out of time. 浏览器重定向到perl_code.pl并提供404.我目前正在耗尽时间。 simple answers will be appreciated. 简单的答案将不胜感激。

EDIT: 编辑:

This is a servlet program, so also suggest any modifications to web.xml if any. 这是一个servlet程序,因此如果有的话,还建议对web.xml进行任何修改。

You can't redirect after an output to stdout. 输出到stdout后无法重定向。 Either redirect or print, not both. 重定向或打印,而不是两者。 Check that your system call doesn't do anything to stdout; 检查你的system调用对stdout没有任何作用; or even better, redirect its stdout to something just in case (like /dev/null ). 甚至更好,将其stdout重定向到以防万一(如/dev/null )。

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

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