PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] How to configure apache-vhost.conf file for getting Session value from Java

 September 21, 2022     java, mod-proxy, session, tomcat, virtualhost     No comments   

Issue

Existing Config File setting for VirtualHost in Tomcat Server:

`<VirtualHost *:96>
  ServerName example.in
  ServerAlias www.example.in
  ProxyPass / http://127.0.0.1:8080/example/
  ProxyPassReverse / http://127.0.0.1:8080/example/

  <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
</IfModule>
</VirtualHost>`

By using this configuration I am not able to get the Session Value, which is being set in Java file request.getSession().setAttribute("ActiveSession", output.getParameters().get("userDetailsList"));

I am trying to retrieve the value in jsp by standard jsp code as <%session.getAttribute("ActiveSession")%>

Problem: when I am using website link 'example.in' I'm not getting the session value in JSP.

But using http://127.0.0.1:8080/example/ I am getting the value.

Already Tried :

`<VirtualHost *:96>
  ServerName example.in
  ServerAlias www.example.in
  ProxyPass / http://127.0.0.1:8080/example/
  ProxyPassReverse / http://127.0.0.1:8080/example/
  Session On
  SessionEnv On
  SessionCookieName session path=/
  SessionHeader X-Replace-Session
  <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
</IfModule>

`

Help will be appreciated as I have already wasted 5 good hrs on this.


Solution

If someone is still struggling to get this, here is the working configuration:

<VirtualHost *:96>
 ServerName example.in
 ServerAlias www.example.in
 ProxyPass / http://127.0.0.1:8080/example/
 ProxyPassReverse / http://127.0.0.1:8080/example/
 ProxyPassReverseCookiePath / http://127.0.0.1:8080/example/
 <IfModule mod_jk.c>
  JkMount /*.jsp ajp13
  JkMount /*.do ajp13
  JkMount /*.* ajp13
  JkMount /servlet/* ajp13
  JkMount /servlets/* ajp13
 </IfModule>
</VirtualHost>


Answered By - amarmishra
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing