i have created 2 files
1.chat.html

<HTML>
    <HEAD>
        <TITLE>Enter your name</TITLE>
    </HEAD>

    <BODY>
        <H1>Enter your name</H1>
        <FORM NAME="form1" ACTION="chat123.jsp" METHOD="POST">
            <INPUT TYPE="TEXT" NAME="text">
            <INPUT TYPE="SUBMIT" VALUE="Submit">
        </FORM>
    </BODY>
</HTML>

2.chat123.jsp

<HTML>
    <HEAD>
        <TITLE>
            Using Java in JSP
        </TITLE>
    </HEAD>

    <BODY>
        <H1>Using Java in JSP</H1>
            Your Name is
        
          <% out.println(request.getParameter ("text")); %>
    </BODY>
</HTML>

When i click on the submit button , the text in the text box is supposed to be printed but its not.

Besides this code works properly only in IE , when i run it in Firefox , instead of executing the chat123.jsp file , all the source code is displayed.

I ran all the code in Wampserver .
i have no idea where i went wrong , i would be glad if you guys can help me out.

Dani AI

Generated

Quick summary and final notes (based on the thread): was correct — the JSP had to be served by a Java servlet container, not by the PHP-only WAMP stack. confirmed the page worked after switching to a proper Java container. ’s suggestion to learn the servlet/JSP model is also on point for anyone new to this stack.

Common diagnostic checklist and practical tips:

  • Confirm the page is being requested over HTTP (for example using a localhost URL and the servlet container port) rather than opened as a local file. Browsers will show raw source when a server-side technology isn’t being executed.
  • Verify a servlet container is running and that the JSP is deployed inside the webapp context (not just sitting in the Apache/PHP document root). Check the container’s logs for JSP compilation/runtime errors.
  • Use browser developer tools to inspect the response headers and body. If the response contains JSP tags or scriptlets, the container is not processing the file.
  • Double-check the form action URL resolves to the correct context path on the servlet container. Relative paths behave differently depending on how the files are served.
  • When both PHP and Java must run on the same host, keep Apache (or WAMP/XAMPP) for PHP and forward JSP requests to a servlet container, or run a single container that supports both technologies via a connector. For local development, an IDE that bundles a servlet container can simplify deployment.

References for deeper reading and alternatives:

Recommended Answers

All 6 Replies

May be your right. but is there any way i can perform this simple task of just printing the text.

Download netbean sdk. It will be suitable for you.

Download netbean sdk. It will be suitable for you.

IDE is irrelevant

Besides this code works properly only in IE , when i run it in Firefox , instead of executing the chat123.jsp file , all the source code is displayed.

I ran all the code in Wampserver .
i have no idea where i went wrong , i would be glad if you guys can help me out.

Problem is obvious

  • all the source code is displayed
  • I ran all the code in Wampserver

WAMP is for PHP not Java (You could possible run it on that Apache server, but that would require additional configuration which is not always the simple one). You need Tomcat and because you do not have or not running Tomcat you see whole source code

kudos to peter_budo , yeah now i get this stuff ...
its printing the text i enter.

Is there any web server which is generic and runs all the web technologies like PHP and JSP n all .

You can make Tomcat add-on of your existing Apache server (from WAMPP) if you use mod_jk

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.