Why JSTL tags in JSP were not working locally?

I have created two JSP pages (toBeImportedPage.jsp and mainPage.jsp). I need to import the toBeImportedPage.jsp inside the mainPage.jsp. To achieve this I have used JSTL tag libraries (<%@ taglib uri=”http://java.sun.com/jstl/core&#8221; prefix=”c”%>) in the mainPage.jsp and <c:import> tag to import the jsp. Both JSP pages are in the same folder location.

Find below the code for my mainPage.jsp page –

<%@ taglib uri=”http://java.sun.com/jstl/core&#8221; prefix=”c”%>
<HTML>
<HEAD>
<TITLE>  Main JSP </TITLE>
</HEAD>
<BODY>
<form method=”post” name=”LeadTimeForm” action=”” onSubmit=”return validateLeadTimeForm()”>
<c:import url=”/toBeImportedPage.jsp”/>
</form>
</BODY>
</HTML>

You can use any HTML editor to created the above two JSP pages. I have used EditPlus editor. When I tried to execute or run my mainPage.jsp page from the editor, I see the blank page. The toBeImportedPage.jsp page is not imported.

I have cross checked if there may be something wrong in using the JSTL tags in the JSP, but everything was correctly used. But still I’m not able to see my imported JSP.

After struggling for some time, I have found that the JSTL tags will be understood and executed by the JSP compiler only after the JSP is converted into Servlet class. To happen this conversion the JSP pages should be deployed in to any Application Server.

So in my case I have used Jdeveloper and proceeded as listed below –

  1. Created a Java Project
  2. Added my two JSP pages.
  3. Created an WAR or EAR file for the Java Project.
  4. Deployed the EAR or WAR file into Weblogic Application server.
  5. Executed the mainPage.jsp page from the Weblogic server.

Hurry !!! Now I can view the imported jsp (toBeImportedPage.jsp) in the main JSP (mainPage.jsp).

Conclusion:

So in case if we find any of the tag libraries are not working while executing from the editor, that simply means the JSP pages need to be deployed into an Application Server and need to execute.

Advertisements
This entry was posted in JSP, JSTL and tagged , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s