0

自宅からラップトップで Web サイトをホストしています html/servlets を apache tomcat と一緒に使用しています server.xml ファイルを変更し、プロジェクト ディレクトリに ROOT.xml ファイルを作成することで、Tomcat をセットアップして仮想サーバーをホストしましたcatalina フォルダーは、ルーター設定でラップトップのポート 8080 も転送しました

ここに問題があります。グローバル IP を使用して自分のサイトに接続するたびに、html ファイルであるホームページに問題なくアクセスできます。ホームページ

しかし、ログインとパスワードを入力してログインすると、何らかの理由でApacheがサーバーマシンではなくクライアントマシン(localhost)でサーブレットファイルを見つけようとし、すべてのフォームアクションとリダイレクトを変更して、適切なサーブレット ファイルとともにグローバル ip を使用しますが、それでも自動的にローカル ホストに変更されます。 自動リダイレクト

このため、サイトの残りの部分にアクセスできません

誰でも助けることができますか?

PS.i は、自分のネットワーク上にあるデスクトップと、別のネットワーク上にある別のラップトップからサイトを試しましたが、同じことが起こり続けます。

ありがとう

ログイン サーブレットのコードを次に示します。他のサーブレットは同様のデータベース接続とリダイレクトを持っています。

//Log in check

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;

public class Login extends HttpServlet
{

public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,      ServletException
{
PrintWriter out=res.getWriter();
Connection con;
Statement s;
ResultSet rs;
ResultSet rs2;

try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://27.4.230.15:3306/irides","root",".hack%//sign66    ");
s=con.createStatement();
try{
String sap=req.getParameter("user");
rs=s.executeQuery("select passwd from participant where sap='"+sap+"'");
if(rs.next()){
if(rs.getObject(1).toString().equals(req.getParameter("passwd"))){
HttpSession ss=req.getSession();
ss.setAttribute("sap",sap);
rs2=s.executeQuery("select * from team where sap="+sap);
ss.setAttribute("team",rs2);
rs2=s.executeQuery("select pname,points from participant order by points desc limit 1,     10");
ss.setAttribute("lead",rs2);
ss.setAttribute("ctr",0);
res.sendRedirect("http://27.4.230.15:8080/irides/User");
}
else{
out.println("<html><body>Either the username or the password is incorrect. You will be     redirected to the login page shortly</body></html>");
res.sendRedirect("http://iridescence.in/incorrectPass.html");
}
}
}
catch(Exception e)
{
out.println(e);
out.println("<html><body>A problem was encountered due to which the operation could not     be completed. Please go back to the login page and try again.</body></html>");
}
}
catch(Exception e)
{
out.println(e);
}
}

public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,     ServletException
{
doGet(req,res);
}

}

@ みんな....それは本当にばかげた間違いでした...サーブレットにリダイレクトしていたホームページのhtmlファイルのフォームアクションリンクを変更するのを忘れていました。何らかの理由で、そのファイルでエラーの原因を確認することを完全に忘れていました

4

1 に答える 1

1

私によると、あなたはローカルホストで作業してテストしていると思います。コーディング側で、ローカルホスト:8080 /ファイル名をリダイレクトするためのリンクを指定しましたが、ローカルホストのリンクをそれぞれのサーバーIPに変更する必要があります。サーバー上で..私はあなたがファイル名でローカルホストを変更しなかったと思います..サーバーのディレクトリパスでserveripを使用することを変更します..うまくいけば、それはあなたが確信が持てないのを助けるでしょう

于 2013-01-19T10:16:40.083 に答える